Skip to content

Commit 52c35bd

Browse files
author
Julien Gilli
committed
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.
1 parent 8b00d74 commit 52c35bd

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

lib/timers.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ function listOnTimeout() {
8383
debug('timeout callback ' + msecs);
8484

8585
var now = Timer.now();
86-
// now's value has been updated, consider that it doesn't need to be updated
87-
// unless a timer is added within the loop that processes the timers list
88-
// below
89-
list._addedTimer = false;
9086
debug('now: %d', now);
9187

9288
var first;
@@ -95,10 +91,9 @@ function listOnTimeout() {
9591
// update the value of "now" so that timing computations are
9692
// done correctly. See test/simple/test-timers-blocking-callback.js
9793
// for more information.
98-
if (list._addedTimer) {
94+
if (now < first._monotonicStartTime) {
9995
now = Timer.now();
10096
debug('now: %d', now);
101-
list._addedTimer = false;
10297
}
10398

10499
var diff = now - first._monotonicStartTime;
@@ -198,12 +193,6 @@ exports.active = function(item) {
198193
}
199194

200195
list = lists[msecs];
201-
// Set _addedTimer so that listOnTimeout can refresh
202-
// its current time value to avoid wrong timing computation
203-
// in case timers callback block for a while.
204-
// See test/simple/test-timers-blocking-callback.js for more
205-
// details
206-
list._addedTimer = true;
207196
}
208197
};
209198

0 commit comments

Comments
 (0)