@ -23,6 +23,8 @@ var Timer = process.binding('timer_wrap').Timer;
var L = require ( '_linklist' ) ;
var L = require ( '_linklist' ) ;
var assert = require ( 'assert' ) . ok ;
var assert = require ( 'assert' ) . ok ;
var kOnTimeout = Timer . kOnTimeout | 0 ;
// Timeout values > TIMEOUT_MAX are set to 1.
// Timeout values > TIMEOUT_MAX are set to 1.
var TIMEOUT_MAX = 2147483647 ; // 2^31-1
var TIMEOUT_MAX = 2147483647 ; // 2^31-1
@ -62,7 +64,7 @@ function insert(item, msecs) {
lists [ msecs ] = list ;
lists [ msecs ] = list ;
list . msecs = msecs ;
list . msecs = msecs ;
list . ontimeout = listOnTimeout ;
list [ kOnTimeout ] = listOnTimeout ;
}
}
L . append ( list , item ) ;
L . append ( list , item ) ;
@ -109,7 +111,7 @@ function listOnTimeout() {
} finally {
} finally {
if ( threw ) {
if ( threw ) {
process . nextTick ( function ( ) {
process . nextTick ( function ( ) {
list . ontimeout ( ) ;
list [ kOnTimeout ] ( ) ;
} ) ;
} ) ;
}
}
}
}
@ -215,8 +217,8 @@ exports.setTimeout = function(callback, after) {
exports . clearTimeout = function ( timer ) {
exports . clearTimeout = function ( timer ) {
if ( timer && ( timer . ontimeout || timer . _ onTimeout ) ) {
if ( timer && ( timer [ kOnTimeout ] || timer . _ onTimeout ) ) {
timer . ontimeout = timer . _ onTimeout = null ;
timer [ kOnTimeout ] = timer . _ onTimeout = null ;
if ( timer instanceof Timeout ) {
if ( timer instanceof Timeout ) {
timer . close ( ) ; // for after === 0
timer . close ( ) ; // for after === 0
} else {
} else {
@ -283,7 +285,7 @@ Timeout.prototype.unref = function() {
if ( delay < 0 ) delay = 0 ;
if ( delay < 0 ) delay = 0 ;
exports . unenroll ( this ) ;
exports . unenroll ( this ) ;
this . _ handle = new Timer ( ) ;
this . _ handle = new Timer ( ) ;
this . _ handle . ontimeout = this . _ onTimeout ;
this . _ handle [ kOnTimeout ] = this . _ onTimeout ;
this . _ handle . start ( delay , 0 ) ;
this . _ handle . start ( delay , 0 ) ;
this . _ handle . domain = this . domain ;
this . _ handle . domain = this . domain ;
this . _ handle . unref ( ) ;
this . _ handle . unref ( ) ;
@ -300,7 +302,7 @@ Timeout.prototype.ref = function() {
Timeout . prototype . close = function ( ) {
Timeout . prototype . close = function ( ) {
this . _ onTimeout = null ;
this . _ onTimeout = null ;
if ( this . _ handle ) {
if ( this . _ handle ) {
this . _ handle . ontimeout = null ;
this . _ handle [ kOnTimeout ] = null ;
this . _ handle . close ( ) ;
this . _ handle . close ( ) ;
} else {
} else {
exports . unenroll ( this ) ;
exports . unenroll ( this ) ;
@ -439,7 +441,7 @@ exports._unrefActive = function(item) {
unrefTimer = new Timer ( ) ;
unrefTimer = new Timer ( ) ;
unrefTimer . unref ( ) ;
unrefTimer . unref ( ) ;
unrefTimer . when = - 1 ;
unrefTimer . when = - 1 ;
unrefTimer . ontimeout = unrefTimeout ;
unrefTimer [ kOnTimeout ] = unrefTimeout ;
}
}
var now = Timer . now ( ) ;
var now = Timer . now ( ) ;