@ -315,19 +315,18 @@
} ;
} ;
startup . processNextTick = function ( ) {
startup . processNextTick = function ( ) {
var lastThrew = false ;
var nextTickQueue = [ ] ;
var nextTickQueue = [ ] ;
var needSpinner = true ;
var inTick = false ;
// this infob ox thing is used so that the C++ code in src/node.cc
// this infoBox thing is used so that the C++ code in src/node.cc
// can have easy accesss to our nextTick state, and avoid unnecessary
// can have easy accesss to our nextTick state, and avoid unnecessary
// calls into process._tickCallback.
// calls into process._tickCallback.
// order is [length, index]
// order is [length, index, inTick, lastThrew ]
// Never write code like this without very good reason!
// Never write code like this without very good reason!
var infoBox = process . _ tickInfoBox ;
var infoBox = process . _ tickInfoBox ;
var length = 0 ;
var length = 0 ;
var index = 1 ;
var index = 1 ;
var inTick = 2 ;
var lastThrew = 3 ;
process . nextTick = nextTick ;
process . nextTick = nextTick ;
// needs to be accessible from cc land
// needs to be accessible from cc land
@ -335,11 +334,6 @@
process . _ tickCallback = _ tickCallback ;
process . _ tickCallback = _ tickCallback ;
process . _ tickDomainCallback = _ tickDomainCallback ;
process . _ tickDomainCallback = _ tickDomainCallback ;
function Tock ( cb , domain ) {
this . callback = cb ;
this . domain = domain ;
}
function tickDone ( ) {
function tickDone ( ) {
if ( infoBox [ length ] !== 0 ) {
if ( infoBox [ length ] !== 0 ) {
if ( infoBox [ length ] <= infoBox [ index ] ) {
if ( infoBox [ length ] <= infoBox [ index ] ) {
@ -350,7 +344,7 @@
infoBox [ length ] = nextTickQueue . length ;
infoBox [ length ] = nextTickQueue . length ;
}
}
}
}
inTick = false ;
infoBox [ inTick ] = 0 ;
infoBox [ index ] = 0 ;
infoBox [ index ] = 0 ;
}
}
@ -359,12 +353,12 @@
function _ tickCallback ( ) {
function _ tickCallback ( ) {
var callback , nextTickLength , threw ;
var callback , nextTickLength , threw ;
if ( inTick ) return ;
if ( infoBox [ in Tick ] === 1 ) return ;
if ( infoBox [ length ] === 0 ) {
if ( infoBox [ length ] === 0 ) {
infoBox [ index ] = 0 ;
infoBox [ index ] = 0 ;
return ;
return ;
}
}
inTick = true ;
infoBox [ inTick ] = 1 ;
while ( infoBox [ index ] < infoBox [ length ] ) {
while ( infoBox [ index ] < infoBox [ length ] ) {
callback = nextTickQueue [ infoBox [ index ] ++ ] . callback ;
callback = nextTickQueue [ infoBox [ index ] ++ ] . callback ;
@ -383,17 +377,17 @@
function _ tickDomainCallback ( ) {
function _ tickDomainCallback ( ) {
var nextTickLength , tock , callback ;
var nextTickLength , tock , callback ;
if ( lastThrew ) {
if ( infoBox [ lastThrew ] === 1 ) {
lastThrew = false ;
infoBox [ lastThrew ] = 0 ;
return ;
return ;
}
}
if ( inTick ) return ;
if ( infoBox [ in Tick ] === 1 ) return ;
if ( infoBox [ length ] === 0 ) {
if ( infoBox [ length ] === 0 ) {
infoBox [ index ] = 0 ;
infoBox [ index ] = 0 ;
return ;
return ;
}
}
inTick = true ;
infoBox [ inTick ] = 1 ;
while ( infoBox [ index ] < infoBox [ length ] ) {
while ( infoBox [ index ] < infoBox [ length ] ) {
tock = nextTickQueue [ infoBox [ index ] ++ ] ;
tock = nextTickQueue [ infoBox [ index ] ++ ] ;
@ -402,12 +396,12 @@
if ( tock . domain . _ disposed ) continue ;
if ( tock . domain . _ disposed ) continue ;
tock . domain . enter ( ) ;
tock . domain . enter ( ) ;
}
}
lastThrew = true ;
infoBox [ lastThrew ] = 1 ;
try {
try {
callback ( ) ;
callback ( ) ;
lastThrew = false ;
infoBox [ lastThrew ] = 0 ;
} finally {
} finally {
if ( lastThrew ) tickDone ( ) ;
if ( infoBox [ lastThrew ] === 1 ) tickDone ( ) ;
}
}
if ( tock . domain )
if ( tock . domain )
tock . domain . exit ( ) ;
tock . domain . exit ( ) ;
@ -421,7 +415,7 @@
if ( process . _ exiting )
if ( process . _ exiting )
return ;
return ;
nextTickQueue . push ( new Tock ( callback , null ) ) ;
nextTickQueue . push ( { callback : callback , domain : null } ) ;
infoBox [ length ] ++ ;
infoBox [ length ] ++ ;
}
}
@ -430,7 +424,7 @@
if ( process . _ exiting )
if ( process . _ exiting )
return ;
return ;
nextTickQueue . push ( new Tock ( callback , process . domain ) ) ;
nextTickQueue . push ( { callback : callback , domain : process . domain } ) ;
infoBox [ length ] ++ ;
infoBox [ length ] ++ ;
}
}
} ;
} ;