Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
renderjs
Commits
b9e4d9a8
Commit
b9e4d9a8
authored
May 11, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce number of created Queue.
Reuse Queue created from callback directly.
parent
7703c036
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
33 deletions
+42
-33
renderjs.js
renderjs.js
+41
-27
test/renderjs_test.js
test/renderjs_test.js
+1
-6
No files found.
renderjs.js
View file @
b9e4d9a8
...
@@ -10,6 +10,25 @@
...
@@ -10,6 +10,25 @@
Event
,
URL
)
{
Event
,
URL
)
{
"
use strict
"
;
"
use strict
"
;
function
ensurePushableQueue
(
callback
,
argument_list
,
context
)
{
var
result
;
try
{
result
=
callback
.
apply
(
context
,
argument_list
);
}
catch
(
e
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
returnPushableError
()
{
return
RSVP
.
reject
(
e
);
});
}
if
(
result
instanceof
RSVP
.
Queue
)
{
return
result
;
}
return
new
RSVP
.
Queue
()
.
push
(
function
returnPushableResult
()
{
return
result
;
});
}
function
readBlobAsDataURL
(
blob
)
{
function
readBlobAsDataURL
(
blob
)
{
var
fr
=
new
FileReader
();
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
waitFormDataURLRead
(
resolve
,
reject
)
{
return
new
RSVP
.
Promise
(
function
waitFormDataURLRead
(
resolve
,
reject
)
{
...
@@ -194,10 +213,7 @@
...
@@ -194,10 +213,7 @@
return
queue
return
queue
.
push
(
function
generateMutexUnlock
()
{
.
push
(
function
generateMutexUnlock
()
{
return
function
runAndUnlock
(
callback
)
{
return
function
runAndUnlock
(
callback
)
{
return
new
RSVP
.
Queue
()
return
ensurePushableQueue
(
callback
)
.
push
(
function
executeMutexCallback
()
{
return
callback
();
})
.
push
(
function
releaseMutexAfterSuccess
(
result
)
{
.
push
(
function
releaseMutexAfterSuccess
(
result
)
{
current_defer
.
resolve
(
result
);
current_defer
.
resolve
(
result
);
return
result
;
return
result
;
...
@@ -583,10 +599,7 @@
...
@@ -583,10 +599,7 @@
};
};
function
runJob
(
gadget
,
name
,
callback
,
argument_list
)
{
function
runJob
(
gadget
,
name
,
callback
,
argument_list
)
{
var
job_promise
=
new
RSVP
.
Queue
()
var
job_promise
=
ensurePushableQueue
(
callback
,
argument_list
,
gadget
);
.
push
(
function
waitForJobCallback
()
{
return
callback
.
apply
(
gadget
,
argument_list
);
});
if
(
gadget
.
__job_dict
.
hasOwnProperty
(
name
))
{
if
(
gadget
.
__job_dict
.
hasOwnProperty
(
name
))
{
gadget
.
__job_dict
[
name
].
cancel
();
gadget
.
__job_dict
[
name
].
cancel
();
}
}
...
@@ -661,8 +674,7 @@
...
@@ -661,8 +674,7 @@
}
}
return
context
[
mutex_name
].
lockAndRun
(
waitForMethodCallback
);
return
context
[
mutex_name
].
lockAndRun
(
waitForMethodCallback
);
}
}
return
new
RSVP
.
Queue
()
return
ensurePushableQueue
(
callback
,
argument_list
,
context
);
.
push
(
waitForMethodCallback
);
};
};
// Allow chain
// Allow chain
return
this
;
return
this
;
...
@@ -719,10 +731,11 @@
...
@@ -719,10 +731,11 @@
}
}
if
(
modified
&&
context
.
__state_change_callback
!==
undefined
)
{
if
(
modified
&&
context
.
__state_change_callback
!==
undefined
)
{
context
.
__modification_dict
=
modification_dict
;
context
.
__modification_dict
=
modification_dict
;
return
new
RSVP
.
Queue
()
return
ensurePushableQueue
(
.
push
(
function
waitForStateChangeCallback
()
{
context
.
__state_change_callback
,
return
context
.
__state_change_callback
(
modification_dict
);
[
modification_dict
],
})
context
)
.
push
(
function
handleStateChangeSuccess
(
result
)
{
.
push
(
function
handleStateChangeSuccess
(
result
)
{
delete
context
.
__modification_dict
;
delete
context
.
__modification_dict
;
return
result
;
return
result
;
...
@@ -755,11 +768,11 @@
...
@@ -755,11 +768,11 @@
}
}
}
}
return
new
RSVP
.
Queue
()
return
ensurePushableQueue
(
.
push
(
function
waitForAcquireMethod
()
{
aq_dict
[
method_name
],
return
aq_dict
[
method_name
].
apply
(
gadget
,
[
argument_list
,
gadget_scope
]
,
[
argument_list
,
gadget_scope
]);
gadget
}
)
)
.
push
(
undefined
,
function
handleAcquireMethodError
(
error
)
{
.
push
(
undefined
,
function
handleAcquireMethodError
(
error
)
{
if
(
error
instanceof
renderJS
.
AcquisitionError
)
{
if
(
error
instanceof
renderJS
.
AcquisitionError
)
{
return
gadget
.
__aq_parent
(
method_name
,
argument_list
);
return
gadget
.
__aq_parent
(
method_name
,
argument_list
);
...
@@ -773,10 +786,11 @@
...
@@ -773,10 +786,11 @@
this
.
prototype
[
name
]
=
function
acquireMethod
()
{
this
.
prototype
[
name
]
=
function
acquireMethod
()
{
var
argument_list
=
Array
.
prototype
.
slice
.
call
(
arguments
,
0
),
var
argument_list
=
Array
.
prototype
.
slice
.
call
(
arguments
,
0
),
gadget
=
this
;
gadget
=
this
;
return
new
RSVP
.
Queue
()
return
ensurePushableQueue
(
.
push
(
function
waitForAqParent
()
{
gadget
.
__aq_parent
,
return
gadget
.
__aq_parent
(
method_name_to_acquire
,
argument_list
);
[
method_name_to_acquire
,
argument_list
],
});
gadget
);
};
};
// Allow chain
// Allow chain
...
@@ -962,10 +976,10 @@
...
@@ -962,10 +976,10 @@
});
});
}
}
);
);
return
new
RSVP
.
Queue
()
.
push
(
function
waitForChannelCall
()
{
return
ensurePushableQueue
(
function
waitForChannelCall
()
{
return
wait_promise
;
return
wait_promise
;
});
});
};
};
return
"
OK
"
;
return
"
OK
"
;
}
}
...
...
test/renderjs_test.js
View file @
b9e4d9a8
...
@@ -1675,15 +1675,10 @@
...
@@ -1675,15 +1675,10 @@
gadget
=
new
Klass
();
gadget
=
new
Klass
();
stop
();
stop
();
expect
(
2
);
expect
(
1
);
gadget
.
checkIfAqParentIsUndefined
()
gadget
.
checkIfAqParentIsUndefined
()
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
TypeError
);
ok
(
error
instanceof
TypeError
);
ok
((
error
.
message
===
"
gadget.__aq_parent is not a function
"
)
||
(
error
.
message
===
"
undefined is not a function
"
)
||
(
error
.
message
.
indexOf
(
"
__aq_parent
"
)
!==
-
1
),
error
);
})
})
.
always
(
function
()
{
.
always
(
function
()
{
start
();
start
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment