Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
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 @@
Event
,
URL
)
{
"
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
)
{
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
waitFormDataURLRead
(
resolve
,
reject
)
{
...
...
@@ -194,10 +213,7 @@
return
queue
.
push
(
function
generateMutexUnlock
()
{
return
function
runAndUnlock
(
callback
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
executeMutexCallback
()
{
return
callback
();
})
return
ensurePushableQueue
(
callback
)
.
push
(
function
releaseMutexAfterSuccess
(
result
)
{
current_defer
.
resolve
(
result
);
return
result
;
...
...
@@ -583,10 +599,7 @@
};
function
runJob
(
gadget
,
name
,
callback
,
argument_list
)
{
var
job_promise
=
new
RSVP
.
Queue
()
.
push
(
function
waitForJobCallback
()
{
return
callback
.
apply
(
gadget
,
argument_list
);
});
var
job_promise
=
ensurePushableQueue
(
callback
,
argument_list
,
gadget
);
if
(
gadget
.
__job_dict
.
hasOwnProperty
(
name
))
{
gadget
.
__job_dict
[
name
].
cancel
();
}
...
...
@@ -661,8 +674,7 @@
}
return
context
[
mutex_name
].
lockAndRun
(
waitForMethodCallback
);
}
return
new
RSVP
.
Queue
()
.
push
(
waitForMethodCallback
);
return
ensurePushableQueue
(
callback
,
argument_list
,
context
);
};
// Allow chain
return
this
;
...
...
@@ -719,10 +731,11 @@
}
if
(
modified
&&
context
.
__state_change_callback
!==
undefined
)
{
context
.
__modification_dict
=
modification_dict
;
return
new
RSVP
.
Queue
()
.
push
(
function
waitForStateChangeCallback
()
{
return
context
.
__state_change_callback
(
modification_dict
);
})
return
ensurePushableQueue
(
context
.
__state_change_callback
,
[
modification_dict
],
context
)
.
push
(
function
handleStateChangeSuccess
(
result
)
{
delete
context
.
__modification_dict
;
return
result
;
...
...
@@ -755,11 +768,11 @@
}
}
return
new
RSVP
.
Queue
()
.
push
(
function
waitForAcquireMethod
()
{
return
aq_dict
[
method_name
].
apply
(
gadget
,
[
argument_list
,
gadget_scope
]);
}
)
return
ensurePushableQueue
(
aq_dict
[
method_name
],
[
argument_list
,
gadget_scope
]
,
gadget
)
.
push
(
undefined
,
function
handleAcquireMethodError
(
error
)
{
if
(
error
instanceof
renderJS
.
AcquisitionError
)
{
return
gadget
.
__aq_parent
(
method_name
,
argument_list
);
...
...
@@ -773,10 +786,11 @@
this
.
prototype
[
name
]
=
function
acquireMethod
()
{
var
argument_list
=
Array
.
prototype
.
slice
.
call
(
arguments
,
0
),
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
waitForAqParent
()
{
return
gadget
.
__aq_parent
(
method_name_to_acquire
,
argument_list
);
});
return
ensurePushableQueue
(
gadget
.
__aq_parent
,
[
method_name_to_acquire
,
argument_list
],
gadget
);
};
// Allow chain
...
...
@@ -962,10 +976,10 @@
});
}
);
return
new
RSVP
.
Queue
()
.
push
(
function
waitForChannelCall
()
{
return
wait_promise
;
});
return
ensurePushableQueue
(
function
waitForChannelCall
()
{
return
wait_promise
;
});
};
return
"
OK
"
;
}
...
...
test/renderjs_test.js
View file @
b9e4d9a8
...
...
@@ -1675,15 +1675,10 @@
gadget
=
new
Klass
();
stop
();
expect
(
2
);
expect
(
1
);
gadget
.
checkIfAqParentIsUndefined
()
.
fail
(
function
(
error
)
{
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
()
{
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