(list, now)
| 544 | } |
| 545 | |
| 546 | function listOnTimeout(list, now) { |
| 547 | const msecs = list.msecs; |
| 548 | |
| 549 | debug('timeout callback %d', msecs); |
| 550 | |
| 551 | let ranAtLeastOneTimer = false; |
| 552 | let timer; |
| 553 | while ((timer = L.peek(list)) != null) { |
| 554 | const diff = now - timer._idleStart; |
| 555 | |
| 556 | // Check if this loop iteration is too early for the next timer. |
| 557 | // This happens if there are more timers scheduled for later in the list. |
| 558 | if (diff < msecs) { |
| 559 | list.expiry = MathMax(timer._idleStart + msecs, now + 1); |
| 560 | list.id = timerListId++; |
| 561 | timerListQueue.percolateDown(1); |
| 562 | debug('%d list wait because diff is %d', msecs, diff); |
| 563 | return; |
| 564 | } |
| 565 | |
| 566 | if (ranAtLeastOneTimer) |
| 567 | runNextTicks(); |
| 568 | else |
| 569 | ranAtLeastOneTimer = true; |
| 570 | |
| 571 | // The actual logic for when a timeout happens. |
| 572 | L.remove(timer); |
| 573 | |
| 574 | const asyncId = timer[async_id_symbol]; |
| 575 | |
| 576 | if (!timer._onTimeout) { |
| 577 | if (!timer._destroyed) { |
| 578 | timer._destroyed = true; |
| 579 | |
| 580 | if (timer[kHasPrimitive]) |
| 581 | delete knownTimersById[asyncId]; |
| 582 | |
| 583 | if (timer[kRefed]) |
| 584 | timeoutInfo[0]--; |
| 585 | |
| 586 | emitDestroy(asyncId); |
| 587 | } |
| 588 | continue; |
| 589 | } |
| 590 | |
| 591 | const priorContextFrame = |
| 592 | AsyncContextFrame.exchange(timer[async_context_frame]); |
| 593 | |
| 594 | emitBefore(asyncId, timer[trigger_async_id_symbol], timer); |
| 595 | |
| 596 | let start; |
| 597 | if (timer._repeat) { |
| 598 | // We need to use the binding as the receiver for fast API calls. |
| 599 | start = binding.getLibuvNow(); |
| 600 | } |
| 601 | |
| 602 | try { |
| 603 | const args = timer._timerArgs; |
no test coverage detected
searching dependent graphs…