smelt.task¶
Tier: Host — Available in every runtime, including headless mode.
Yield-then-resume coroutine bridge: alloc and resume external tasks.
smelt.task.all¶
Run fns concurrently; wait for all to finish. Returns an array of
results in the same order as the input. Errors from any branch
propagate; the remaining branches still complete and their results
are discarded. Must run inside a yielding context.
smelt.task.alloc¶
Allocate and return a fresh external task id used to pair a yielded coroutine with a later task.resume call.
smelt.task.external¶
Allocate an external task id, invoke start(id) to kick off whatever
will eventually call smelt.task.resume(id, value) (or resolve through
the Rust resume sink), and park until that resolution arrives. Returns
the resolved value. Raises cancelled if the task is cancelled while
parked. Plugin authors bridging custom Rust extensions use this to
avoid hand-rolling the alloc + start + wait dance.
smelt.task.race¶
Run fns concurrently; first to return wins. Returns the winner's
(index, result) as multi-value, mirroring task.timeout's
(value, err) shape. All other branches are cancelled. Errors from
any branch propagate (losers cancelled first). Must run inside a
yielding context.
smelt.task.resume¶
Resume the yielded task id with value. The runtime delivers value as the return of the matching coroutine.yield.
smelt.task.timeout¶
Run fn with an ms-millisecond deadline. Returns (result, nil) if
fn finishes in time, or (nil, "timeout") if the deadline fires
first — in which case fn's coroutine is cancelled (any in-flight
smelt.sleep / task.wait raises cancelled and the coroutine
unwinds). Must run inside a yielding context.
smelt.task.wait¶
Park the running task until smelt.task.resume(id, value) fires. Returns the resumed value.