This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make process.nextTick worlds faster for large queues.
- Loading branch information
1 parent
60b93cc
commit 81a53e8
Showing
1 changed file
with
5 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,9 +47,12 @@ process.evalcx = function () { | |
var nextTickQueue = []; | ||
|
||
process._tickCallback = function () { | ||
for (var l = nextTickQueue.length; l; l--) { | ||
nextTickQueue.shift()(); | ||
var l = nextTickQueue.length; | ||
if (l === 0) return; | ||
for (var i = 0; i < l; i++) { | ||
nextTickQueue[i](); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
creationix
Author
|
||
} | ||
nextTickQueue.splice(0, l); | ||
}; | ||
|
||
process.nextTick = function (callback) { | ||
|
There is a problem here if nextTickQueue[i] throws an error. The splice is never run and things get confused. The way to fix it is to catch errors, make sure things are spliced and then throw the errors on. Here's a patch to fix the problem (with an example which works after the patch is applied): http://gist.github.com/553061