diff options
author | isaacs <i@izs.me> | 2012-04-06 16:26:18 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-04-17 13:14:55 -0700 |
commit | 963459d736d6594de641aff4d8767da113359457 (patch) | |
tree | 38e18f82599ebed15fbed527c16f392efaceb056 /src/node.js | |
parent | a26bee8fa16bcbdaafdee516288c6f59a43376f5 (diff) | |
download | node-new-963459d736d6594de641aff4d8767da113359457.tar.gz |
Domain feature
This is a squashed commit of the main work done on the domains-wip branch.
The original commit messages are preserved for posterity:
* Implicitly add EventEmitters to active domain
* Implicitly add timers to active domain
* domain: add members, remove ctor cb
* Don't hijack bound callbacks for Domain error events
* Add dispose method
* Add domain.remove(ee) method
* A test of multiple domains in process at once
* Put the active domain on the process object
* Only intercept error arg if explicitly requested
* Typo
* Don't auto-add new domains to the current domain
While an automatic parent/child relationship is sort of neat,
and leads to some nice error-bubbling characteristics, it also
results in keeping a reference to every EE and timer created,
unless domains are explicitly disposed of.
* Explicitly adding one domain to another is still fine, of course.
* Don't allow circular domain->domain memberships
* Disposing of a domain removes it from its parent
* Domain disposal turns functions into no-ops
* More documentation of domains
* More thorough dispose() semantics
* An example using domains in an HTTP server
* Don't handle errors on a disposed domain
* Need to push, even if the same domain is entered multiple times
* Array.push is too slow for the EE Ctor
* lint domain
* domain: docs
* Also call abort and destroySoon to clean up event emitters
* domain: Wrap destroy methods in a try/catch
* Attach tick callbacks to active domain
* domain: Only implicitly bind timers, not explicitly
* domain: Don't fire timers when disposed.
* domain: Simplify naming so that MakeCallback works on Timers
* Add setInterval and nextTick to domain test
* domain: Make stack private
Diffstat (limited to 'src/node.js')
-rw-r--r-- | src/node.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/node.js b/src/node.js index 3322df6d25..05c0dd8ecd 100644 --- a/src/node.js +++ b/src/node.js @@ -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) { @@ -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(); }; }; |