From 127f653c500f1f1405f4b605e8d06aef18eef583 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 | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/timers.js b/lib/timers.js index c45b48e0a2d7..83493eb609ee 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; @@ -196,14 +191,6 @@ exports.active = function(item) { item._monotonicStartTime = Timer.now(); L.append(list, 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; } };