Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
timers: make previous change simpler
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Julien Gilli committed May 9, 2015
1 parent 8b00d74 commit 127f653
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
};

Expand Down

0 comments on commit 127f653

Please sign in to comment.