@ -305,7 +305,6 @@
startup . processNextTick = function ( ) {
startup . processNextTick = function ( ) {
var _ needTickCallback = process . _ needTickCallback ;
var _ needTickCallback = process . _ needTickCallback ;
var nextTickQueue = [ ] ;
var nextTickQueue = [ ] ;
var usingDomains = false ;
var needSpinner = true ;
var needSpinner = true ;
var inTick = false ;
var inTick = false ;
@ -324,6 +323,7 @@
// needs to be accessible from cc land
// needs to be accessible from cc land
process . _ tickDomainCallback = _ tickDomainCallback ;
process . _ tickDomainCallback = _ tickDomainCallback ;
process . nextTick = nextTick ;
process . nextTick = nextTick ;
process . _ nextDomainTick = _ nextDomainTick ;
// the maximum number of times it'll process something like
// the maximum number of times it'll process something like
// nextTick(function f(){nextTick(f)})
// nextTick(function f(){nextTick(f)})
@ -372,10 +372,7 @@
// no callbacks to run
// no callbacks to run
if ( infoBox [ length ] === 0 )
if ( infoBox [ length ] === 0 )
return infoBox [ index ] = infoBox [ depth ] = 0 ;
return infoBox [ index ] = infoBox [ depth ] = 0 ;
if ( nextTickQueue [ infoBox [ length ] - 1 ] . domain )
process . _ tickCallback ( ) ;
_ tickDomainCallback ( ) ;
else
_ tickCallback ( ) ;
}
}
// run callbacks that have no domain
// run callbacks that have no domain
@ -467,16 +464,26 @@
if ( infoBox [ depth ] >= process . maxTickDepth )
if ( infoBox [ depth ] >= process . maxTickDepth )
maxTickWarn ( ) ;
maxTickWarn ( ) ;
var obj = { callback : callback } ;
var obj = { callback : callback , domain : null } ;
if ( process . domain !== null ) {
obj . domain = process . domain ;
nextTickQueue . push ( obj ) ;
// user has opt'd to use domains, so override default functionality
infoBox [ length ] ++ ;
if ( ! usingDomains ) {
process . _ tickCallback = _ tickDomainCallback ;
if ( needSpinner ) {
usingDomains = true ;
_ needTickCallback ( ) ;
needSpinner = false ;
}
}
}
}
function _ nextDomainTick ( callback ) {
// on the way out, don't bother. it won't get fired anyway.
if ( process . _ exiting )
return ;
if ( infoBox [ depth ] >= process . maxTickDepth )
maxTickWarn ( ) ;
var obj = { callback : callback , domain : process . domain } ;
nextTickQueue . push ( obj ) ;
nextTickQueue . push ( obj ) ;
infoBox [ length ] ++ ;
infoBox [ length ] ++ ;