From 52c35bd5c0f06e8d52d686ac6d5f77cbf014a34a Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Wed, 29 Apr 2015 18:03:11 -0700 Subject: [PATCH] timers: make previous change simpler Instead of adding a property on the list of timers, simply compare the current value of what represents the current time if its value is earlier than the time of the current timer being processed. --- lib/timers.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/timers.js b/lib/timers.js index c45b48e0a2d7..940d5cd92517 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -83,10 +83,6 @@ function listOnTimeout() { debug('timeout callback ' + msecs); var now = Timer.now(); - // now's value has been updated, consider that it doesn't need to be updated - // unless a timer is added within the loop that processes the timers list - // below - list._addedTimer = false; debug('now: %d', now); var first; @@ -95,10 +91,9 @@ function listOnTimeout() { // update the value of "now" so that timing computations are // done correctly. See test/simple/test-timers-blocking-callback.js // for more information. - if (list._addedTimer) { + if (now < first._monotonicStartTime) { now = Timer.now(); debug('now: %d', now); - list._addedTimer = false; } var diff = now - first._monotonicStartTime; @@ -198,12 +193,6 @@ exports.active = function(item) { } list = lists[msecs]; - // Set _addedTimer so that listOnTimeout can refresh - // its current time value to avoid wrong timing computation - // in case timers callback block for a while. - // See test/simple/test-timers-blocking-callback.js for more - // details - list._addedTimer = true; } };