317
318
private _unpark(): void {
320
>
this._parkCleanup = undefined;
321
>
}
322
323
private _wake(): void {
325
>
this._unpark();
326
>
// Re-enter the trampoline on a host macrotask, NOT a microtask. This:
327
>
// - coalesces multiple wake() calls in the same tick,
328
>
// - keeps the driver off the caller's stack frame, and
329
>
// - lets the entire pending microtask closure (including microtasks
330
>
// enqueued AFTER this `_wake` call within the same outer microtask
331
>
// -- e.g. `queueMicrotask(...)` calls inside an `AsyncIterable`
332
>
// constructor that runs after `clock.schedule` triggered the wake)
333
>
// drain before the next `_step`. A microtask hop here would queue
334
>
// the driver in FIFO order with those subsequent microtasks, so the
335
>
// driver could run a virtual event before the consumer-side promise
336
>
// chain that depends on it has settled.
337
>
nextMacrotask(this._realApi, this._drive);
338
>
}
339
340
// ---- Run lifecycle --------------------------------------------------