MCPcopy Index your code
hub / github.com/nodejs/node / unenroll

Function unenroll

lib/timers.js:71–104  ·  view source on GitHub ↗
(item)

Source from the content-addressed store, hash-verified

69
70// Remove a timer. Cancels the timeout and resets the relevant timer properties.
71function unenroll(item) {
72 if (item._destroyed)
73 return;
74
75 item._destroyed = true;
76
77 if (item[kHasPrimitive])
78 delete knownTimersById[item[async_id_symbol]];
79
80 emitDestroy(item[async_id_symbol]);
81
82 L.remove(item);
83
84 // We only delete refed lists because unrefed ones are incredibly likely
85 // to come from http and be recreated shortly after.
86 // TODO: Long-term this could instead be handled by creating an internal
87 // clearTimeout that makes it clear that the list should not be deleted.
88 // That function could then be used by http and other similar modules.
89 if (item[kRefed]) {
90 // Compliment truncation during insert().
91 const msecs = MathTrunc(item._idleTimeout);
92 const list = timerListMap[msecs];
93 if (list !== undefined && L.isEmpty(list)) {
94 debug('unenroll: list empty');
95 timerListQueue.removeAt(list.priorityQueuePosition);
96 delete timerListMap[list.msecs];
97 }
98
99 decRefCount();
100 }
101
102 // If active is called later, then we want to make sure not to insert again
103 item._idleTimeout = -1;
104}
105
106
107/**

Callers 1

clearTimeoutFunction · 0.85

Calls 5

decRefCountFunction · 0.85
debugFunction · 0.50
removeMethod · 0.45
isEmptyMethod · 0.45
removeAtMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…