Async
Async in MushScript is a single-threaded, interleaved suspend/resume state machine. There are no threads; every interleaving point is marked explicitly by await.
Asyncasync func declares an async function; await waits for a result. Await is the only interleaving point: code before an await runs atomically, execution suspends at the await to let other tasks run, and picks up where it left off once resumed. To use await, the enclosing function must itself be an async func.
Tasks and Spawnspawn puts a code block into execution immediately and returns a task. A block with a value just returns it, and the block's type is task<T> — no async function declaration needed up front.
Cancellation and TimeoutCancellation produces no error; it follows negotiation semantics: the function declares itself cancellable, and when cancelled it returns a value through an ordinary return in its body — the task completes normally.
Last updated on October 11, 2026
