Skip to main content

run_event_loop

Function run_event_loop 

Source
pub fn run_event_loop() -> Result<(), String>
Expand description

Drive the event loop to quiescence.

Two regimes, selected per iteration by open_handles:

  • No open handles (pure script / timers only): the original deterministic virtual clock — drain microtasks, fire the earliest (delay, seq) timer immediately (no real waiting), repeat until both queues empty, then EXIT. Parity output and test speed are unchanged.
  • Open handles (a server is listening / sockets are live): drain microtasks, fire every timer whose real deadline has passed, then BLOCK on the I/O channel (recv_timeout bounded by the next timer’s real deadline, or unbounded recv if no timers) and run the received IoTask on the main thread. The host keeps its own Sender, so recv never disconnects while the process should stay alive.

Errors thrown by a task/timer/I/O dispatch abort the loop (uncaught → surfaced).