Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A few more list clean ups

  • Loading branch information...
commit 29f48d48e51da1bb3a267584f0101e3b848957ae 1 parent 0999443
@ry ry authored
Showing with 14 additions and 10 deletions.
  1. +9 −10 lib/timers.js
  2. +5 −0 test/simple/test-timers-linked-list.js
View
19 lib/timers.js
@@ -131,7 +131,7 @@ function insert(item, msecs) {
};
}
- if (list._idleNext === list) {
+ if (isEmpty(list)) {
// if empty (re)start the timer
list.again(msecs);
}
@@ -142,16 +142,14 @@ function insert(item, msecs) {
var unenroll = exports.unenroll = function(item) {
- if (item._idleNext) {
- remove(item);
+ remove(item);
- var list = lists[item._idleTimeout];
- // if empty then stop the watcher
- debug('unenroll');
- if (list && isEmpty(list)) {
- debug('unenroll: list empty');
- list.stop();
- }
+ var list = lists[item._idleTimeout];
+ // if empty then stop the watcher
+ debug('unenroll');
+ if (list && isEmpty(list)) {
+ debug('unenroll: list empty');
+ list.stop();
}
};
@@ -166,6 +164,7 @@ exports.enroll = function(item, msecs) {
init(item);
};
+
// call this whenever the item is active (not idle)
// it will reset its timeout.
exports.active = function(item) {
View
5 test/simple/test-timers-linked-list.js
@@ -11,6 +11,11 @@ var D = { name: "D" };
L.init(list);
+L.init(A);
+L.init(B);
+L.init(C);
+L.init(D);
+
assert.ok(L.isEmpty(list));
assert.equal(null, L.peek(list));
Please sign in to comment.
Something went wrong with that request. Please try again.