10000 lib: replace _linklist with ES6 Sets by Trott · Pull Request #2973 · nodejs/node · GitHub
[go: up one dir, main page]

Skip to content
Prev Previous commit
Next Next commit
fixup: rm util/debug
  • Loading branch information
Trott committed Sep 26, 2015
commit 7bf7f713ade7ee7157a69f3302051f4080568ad4
18 changes: 0 additions & 18 deletions lib/timers.js
< 7440 tr data-hunk="4512c56c6be4938908f6e0fde9747e18e93bbe5d74885b002fba314bda75d440" class="show-top-border">
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

const Timer = process.binding('timer_wrap').Timer;
const util = require('util');
const debug = util.debuglog('timer');
const kOnTimeout = Timer.kOnTimeout | 0;

// Timeout values > TIMEOUT_MAX are set to 1.
Expand Down Expand Up @@ -50,18 +48,14 @@ function listOnTimeout() {
var msecs = this.msecs;
var list = this;

debug('timeout callback %d', msecs);

var now = Timer.now();
debug('now: %s', now);

var diff, first, threw;
if (lists[msecs]) {
for (let first of lists[msecs]) {
diff = now - first._idleStart;
if (diff < msecs) {
list.start(msecs - diff, 0);
debug('%d list wait because diff is %d', msecs, diff);
return;
} else {
lists[msecs].delete(first);
Expand Down Expand Up @@ -113,7 +107,6 @@ function listOnTimeoutNT(list) {


const unenroll = exports.unenroll = function(item) {
debug('unenroll');

var list = lists[item._idleTimeout];
if (list) {
Expand All @@ -122,7 +115,6 @@ const unenroll = exports.unenroll = function(item) {

// if empty then stop the watcher
if (list && list.size === 0) {
debug('unenroll: list empty');
if (list.timer) {
list.timer.close();
}
Expand Down Expand Up @@ -500,7 +492,6 @@ function _makeTimerTimeout(timer) {
domain.enter();
}

debug('unreftimer firing timeout');
timer._called = true;
_runOnTimeout(timer);

Expand All @@ -521,8 +512,6 @@ function _runOnTimeout(timer) {
function unrefTimeout() {
var now = Timer.now();

debug('unrefTimer fired');

var timeSinceLastActive;
var nextTimeoutTime;
var nextTimeoutDuration;
Expand Down Expand Up @@ -576,9 +565,6 8FDF @@ function unrefTimeout() {
if (minNextTimeoutTime !== TIMEOUT_MAX) {
unrefTimer.start(minNextTimeoutTime - now, 0);
unrefTimer.when = minNextTimeoutTime;
debug('unrefTimer rescheduled');
} else if (unrefList.size === 0) {
debug('unrefList is empty');
}
}

Expand All @@ -591,10 +577,8 @@ exports._unrefActive = function(item) {
lists[msecs].delete(item);
}
if (!unrefList) {
debug('unrefList initialized');
unrefList = new Set();

debug('unrefTimer initialized');
unrefTimer = new Timer();
unrefTimer.unref();
unrefTimer.when = -1;
Expand All @@ -611,9 +595,7 @@ exports._unrefActive = function(item) {
if (unrefTimer.when === -1 || unrefTimer.when > when) {
unrefTimer.start(msecs, 0);
unrefTimer.when = when;
debug('unrefTimer scheduled');
}

debug('unrefList append to end');
unrefList.add(item);
};
0