Skip to content

Commit

Permalink
timers: use HandleWrap::Unrefed
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishrock123 committed May 3, 2016
1 parent e19c5dd commit 9b62ab0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ function insert(item, unrefed) {
list = new TimersList(msecs, unrefed);
L.init(list);
list._timer._list = list;

if (unrefed === true) list._timer.unref();
list._timer.start(msecs, 0);

lists[msecs] = list;
Expand All @@ -149,7 +147,7 @@ function TimersList(msecs, unrefed) {
this._idleNext = null; // Create the list with the linkedlist properties to
this._idlePrev = null; // prevent any unnecessary hidden class changes.
this._timer = new TimerWrap();
this._unrefed = unrefed;
if (unrefed === true) this._timer.unref();
this.msecs = msecs;
}

Expand Down Expand Up @@ -206,12 +204,12 @@ function listOnTimeout() {
// As such, we can remove the list and clean up the TimerWrap C++ handle.
debug('%d list empty', msecs);
assert(L.isEmpty(list));
this.close();
if (list._unrefed === true) {
delete unrefedLists[msecs];
} else {
if (list._timer.isRefed() === true) {
delete refedLists[msecs];
} else {
delete unrefedLists[msecs];
}
this.close();
}


Expand Down

0 comments on commit 9b62ab0

Please sign in to comment.