This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 10/5/2026.

Pump

~import std/pump

Koru Standard Library: Pump — compile-time composition of participants.

pump.kz · 2 tors

Koru Standard Library: Pump — compile-time composition of participants. · 37 more lines
Koru Standard Library: Pump — compile-time composition of participants. std/pump:create(main) | drained |> std/io:print.ln("all participants retired") std/pump(main) ! step |> tick-step() ! live |> tick-live() ! wait i |> tick-wait(i: i) std/pump:run(main) ! idle |> std/time:sleep-ms(ms: 2) A PARTICIPANT is anything that can answer up to three verbs: step() -> i32 advance every live instance once; return how many made progress this pass. Required. live() -> i64 how many instances are live; 0 = retired. Absent = the participant is immortal — it never drains the pump. wait(i) -> interest instance i's blocking interest — the RETURN TYPE is the vocabulary: `-> i32` fd, `-> i128` re-poll ns, `{ fd, wait_ns }` both; presence, never sentinels. Optional; unarmed participants add nothing to the wait. The join site `std/pump(name)` carries the verbs as `!` arms — the same reference form `std/store(name) ! field` uses for standing watches. Pass order is join order (document order). Each arm's body is compiled into a generated unit `__pump_<name>_{step,live,wait}_<idx>` — the verbs are ordinary calls, so a participant is any author-written unit: a module's singleton state, a hand-managed array, or a `! step` store (which exposes exactly these verbs as `<store>-step` / `<store>-live` / `<store>-wait`). The pump knows none of that — it calls names. `run` drives passes until Σ live() is 0 — a pump of only immortals IS the program's event loop. On an all-idle pass `run` fires `! idle` in the loop; unarmed it composes the wait itself — one `poll()` over every joined `wait` interest capped by the nearest `wait_ns`, else 1ms.

create

keywordcomptimetransformaspirational open-pump-marker-wire koru_std/pump.kz:412

default

keywordcomptimetransform koru_std/pump.kz:526