mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
A few more list clean ups
This commit is contained in:
parent
09994438e5
commit
29f48d48e5
@ -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) {
|
||||
|
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user