()
| 454 | const outstandingQueue = new ImmediateList(); |
| 455 | |
| 456 | function processImmediate() { |
| 457 | const queue = outstandingQueue.head !== null ? |
| 458 | outstandingQueue : immediateQueue; |
| 459 | let immediate = queue.head; |
| 460 | |
| 461 | // Clear the linked list early in case new `setImmediate()` |
| 462 | // calls occur while immediate callbacks are executed |
| 463 | if (queue !== outstandingQueue) { |
| 464 | queue.head = queue.tail = null; |
| 465 | immediateInfo[kHasOutstanding] = 1; |
| 466 | } |
| 467 | |
| 468 | let prevImmediate; |
| 469 | let ranAtLeastOneImmediate = false; |
| 470 | while (immediate !== null) { |
| 471 | if (ranAtLeastOneImmediate) |
| 472 | runNextTicks(); |
| 473 | else |
| 474 | ranAtLeastOneImmediate = true; |
| 475 | |
| 476 | // It's possible for this current Immediate to be cleared while executing |
| 477 | // the next tick queue above, which means we need to use the previous |
| 478 | // Immediate's _idleNext which is guaranteed to not have been cleared. |
| 479 | if (immediate._destroyed) { |
| 480 | outstandingQueue.head = immediate = prevImmediate._idleNext; |
| 481 | continue; |
| 482 | } |
| 483 | |
| 484 | // TODO(RaisinTen): Destroy and unref the Immediate after _onImmediate() |
| 485 | // gets executed, just like how Timeouts work. |
| 486 | immediate._destroyed = true; |
| 487 | |
| 488 | immediateInfo[kCount]--; |
| 489 | if (immediate[kRefed]) |
| 490 | immediateInfo[kRefCount]--; |
| 491 | immediate[kRefed] = null; |
| 492 | |
| 493 | prevImmediate = immediate; |
| 494 | |
| 495 | const priorContextFrame = |
| 496 | AsyncContextFrame.exchange(immediate[async_context_frame]); |
| 497 | |
| 498 | const asyncId = immediate[async_id_symbol]; |
| 499 | emitBefore(asyncId, immediate[trigger_async_id_symbol], immediate); |
| 500 | |
| 501 | try { |
| 502 | const argv = immediate._argv; |
| 503 | if (!argv) |
| 504 | immediate._onImmediate(); |
| 505 | else |
| 506 | immediate._onImmediate(...argv); |
| 507 | } finally { |
| 508 | immediate._onImmediate = null; |
| 509 | |
| 510 | emitDestroy(asyncId); |
| 511 | |
| 512 | outstandingQueue.head = immediate = immediate._idleNext; |
| 513 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…