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

Commit 127f653

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 127f653

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

lib/timers.js

Lines changed: 1 addition & 14 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;
@@ -196,14 +191,6 @@ exports.active = function(item) {
196191
item._monotonicStartTime = Timer.now();
197192
L.append(list, item);
198193
}
199-
200-
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;
207194
}
208195
};
209196

0 commit comments

Comments
 (0)