// A `Task` allows ONE awaiter — a second concurrent `wait` on the same pending // task would overwrite the single `waiter` slot, and completion would wake only // the second, stranding the first forever. Regression (B1.4a review, P1-c): the // guard aborts loudly instead of silently deadlocking. // // aborts (exit 134) after the diagnostic — aarch64-macOS-pinned. #import "modules/std.sx"; sched :: #import "modules/std/sched.sx"; S :: struct { t: *sched.Task(i64); } main :: () -> i64 { st : S = ---; st.t = null; s := sched.Scheduler.init(); ps := @s; pst := @st; mkprod :: (ps: *sched.Scheduler, pst: *S) { pst.t = ps.go(() -> i64 => { ps.yield_now(); 42 }); } mkw :: (ps: *sched.Scheduler, pst: *S) { ps.spawn(() => { x := pst.t.wait() or { -1 }; print("got {}\n", x); }); } mkprod(ps, pst); mkw(ps, pst); mkw(ps, pst); // second waiter → loud abort s.run(); return 0; }