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

Function insert

lib/internal/timers.js:387–408  ·  view source on GitHub ↗
(item, msecs, start = binding.getLibuvNow())

Source from the content-addressed store, hash-verified

385
386// We need to use the binding as the receiver for fast API calls.
387function insert(item, msecs, start = binding.getLibuvNow()) {
388 // Truncate so that accuracy of sub-millisecond timers is not assumed.
389 msecs = MathTrunc(msecs);
390 item._idleStart = start;
391
392 // Use an existing list if there is one, otherwise we need to make a new one.
393 let list = timerListMap[msecs];
394 if (list === undefined) {
395 debug('no %d list was found in insert, creating a new one', msecs);
396 const expiry = start + msecs;
397 timerListMap[msecs] = list = new TimersList(expiry, msecs);
398 timerListQueue.insert(list);
399
400 if (nextExpiry > expiry) {
401 // We need to use the binding as the receiver for fast API calls.
402 binding.scheduleTimer(msecs);
403 nextExpiry = expiry;
404 }
405 }
406
407 L.append(list, item);
408}
409
410function setUnrefTimeout(callback, after) {
411 // Type checking identical to setTimeout()

Callers 7

setTimeoutFunction · 0.85
setIntervalFunction · 0.85
insertGuardedFunction · 0.85
setUnrefTimeoutFunction · 0.85
listOnTimeoutFunction · 0.85
setTimeoutFunction · 0.85
setIntervalFunction · 0.85

Calls 5

getLibuvNowMethod · 0.80
scheduleTimerMethod · 0.80
debugFunction · 0.50
insertMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…