(item)
| 69 | |
| 70 | // Remove a timer. Cancels the timeout and resets the relevant timer properties. |
| 71 | function 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 | /** |
no test coverage detected
searching dependent graphs…