forked from nodejs/node-v0.x-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Julien Gilli
committed
Apr 30, 2015
1 parent
8b00d74
commit 52c35bd
Showing
1 changed file
with
1 addition
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
misterdjules
Owner
|
||
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; | ||
} | ||
}; | ||
|
||
|
This condition is going to be called almost always, while the previous only rarely.