✓
Passing This code compiles and runs correctly.
Code
// MIRROR: a `std/pump` join + run whose participant lives in an imported
// module. `app/lib` holds the singleton's state and answers the three verbs;
// the entry composes them by qualified name — the pump composes names, so
// module qualification is the only thing this test exists to prove.
import std/io
import std/pump
import app/lib
std/pump:create(main)
| drained |> std/io:print.ln("pump drained")
std/pump(main)
! step |> app/lib:step()
! stepped c |> std/io:print.ln("single stepped {{ c:d }}")
! live |> app/lib:live()
! wait i |> app/lib:wait(i)
std/pump:run(main)
Supporting Files
// A singleton pump participant living in an imported module — module-level
// state, no store, the three verbs as plain tors. The entry joins them by
// qualified name; the mirror is that a `std/pump` join + run resolves the
// participant's units across the module boundary.
var count: i64 = 0;
var budget: i64 = 3;
// step() -> i32 — advance once, return progress count. `1` while working,
// `0` when this pass found nothing to do.
~pub tor step {} -> i32
! ?stepped i64
~proc step|zig {
if ($mod.count >= $mod.budget) return 0;
$mod.count += 1;
stepped($mod.count);
return 1;
}
// live() -> i64 — 1 while the participant lives, 0 once retired.
~pub tor live {} -> i64
~proc live|zig {
return @intFromBool($mod.count < $mod.budget);
}
// wait(i) -> { fd, wait_ns } — deadline interest only, 3ms re-poll.
~pub tor wait { i: i64 } -> { fd: i32, wait_ns: i128 }
~proc wait|zig {
_ = i;
return .{ .fd = -1, .wait_ns = 3_000_000 };
}
Actual
single stepped 1
single stepped 2
single stepped 3
pump drained
Expected output
single stepped 1
single stepped 2
single stepped 3
pump drained
Flows
flow ~create click a branch to expand · @labels scroll to their anchor
create (expr: main)
flow ~std/pump click a branch to expand · @labels scroll to their anchor
std/pump (main)
flow ~run click a branch to expand · @labels scroll to their anchor
run (expr: main)
Test Configuration
MUST_RUN