timers: setImmediate process full queue each turn
Previously only one cb per turn of the event loop was processed at a time, which is not exactly what is meant by immediate fixes #5798
This commit is contained in:
parent
c679ac8f00
commit
fa46483fe2
@ -313,18 +313,24 @@ L.init(immediateQueue);
|
|||||||
|
|
||||||
|
|
||||||
function processImmediate() {
|
function processImmediate() {
|
||||||
var immediate = L.shift(immediateQueue);
|
var queue = immediateQueue;
|
||||||
|
|
||||||
if (L.isEmpty(immediateQueue)) {
|
immediateQueue = {};
|
||||||
process._needImmediateCallback = false;
|
L.init(immediateQueue);
|
||||||
|
|
||||||
|
while (L.isEmpty(queue) === false) {
|
||||||
|
var immediate = L.shift(queue);
|
||||||
|
var domain = immediate.domain;
|
||||||
|
if (domain) domain.enter();
|
||||||
|
immediate._onImmediate();
|
||||||
|
if (domain) domain.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (immediate._onImmediate) {
|
// Only round-trip to C++ land if we have to. Calling clearImmediate() on an
|
||||||
if (immediate.domain) immediate.domain.enter();
|
// immediate that's in |queue| is okay. Worst case is we make a superfluous
|
||||||
|
// call to NeedImmediateCallbackSetter().
|
||||||
immediate._onImmediate();
|
if (L.isEmpty(immediateQueue)) {
|
||||||
|
process._needImmediateCallback = false;
|
||||||
if (immediate.domain) immediate.domain.exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user