Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Attach tick callbacks to active domain
  • Loading branch information
isaacs committed Apr 14, 2012
1 parent a914bd0 commit ab886be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/node.js
Expand Up @@ -235,7 +235,13 @@
nextTickQueue = [];

try {
for (var i = 0; i < l; i++) q[i]();
for (var i = 0; i < l; i++) {
var tock = q[i];
var callback = tock.callback;
if (tock.domain) tock.domain.enter();
callback();
if (tock.domain) tock.domain.exit();
}
}
catch (e) {
if (i + 1 < l) {
Expand All @@ -249,7 +255,9 @@
};

process.nextTick = function(callback) {
nextTickQueue.push(callback);
var tock = { callback: callback };
if (process.domain) tock.domain = process.domain;
nextTickQueue.push(tock);
process._needTickCallback();
};
};
Expand Down

0 comments on commit ab886be

Please sign in to comment.