API Reference — Pool — Event source helpers
New to the concept? See Building Blocks — Pool first.
Pool as event source for Io.Select and Io.Future.
Cancel and close in concurrent tasks:
- Pool closed — blocked callers wake with
error.Closed. - Task canceled — the operation returns
error.Canceled.
When a handle becomes available, the Master can react. This is the job-pool pattern:
- Worker returns a handle.
- Master is notified.
- Master submits new work.
PoolResult
pub const PoolResult = union(enum) {
item: ItemHandle,
closed: void,
timeout: void,
canceled: void,
not_created: void,
};
- The handle is inside the result, not behind a pointer. No
*Slotis shared across threads. - When you get
.item, the handle is yours. The pool no longer holds it.
getWaitResult
- Blocking function. No error return — maps all outcomes to
PoolResultvariants. -
Primary building block for Select integration:
-
Also usable with
io.concurrentorgroup.concurrent.
get_wait_future
pub fn get_wait_future(ph: PoolHandle, tag: *const anyopaque, timeout_ns: ?u64) ConcurrentError!Io.Future(PoolResult)
- Thin wrapper:
return p.*.io.concurrent(getWaitResult, .{ph, tag, timeout_ns}). - No heap allocation — args copied by the runtime before
concurrentreturns. - Returns a Future for direct await or
Io.Groupuse. - Returns
error.ConcurrencyUnavailableon single-threaded backends.
Cancel behavior
- On
error.Canceled, returns.canceled— the pool remains open. - Closing is the Master's responsibility.
Next: Hook discipline.