23 · Concurrency
Await deadlines
await task within duration returns a typed timeout Result. On expiry the scheduler requests cancellation and drains the task's cooperative cleanup. A task returning Result produces a nested Result; choose explicitly which layer to propagate. Native work without cancellation checkpoints cannot be forcibly interrupted.
On this page
await task within duration returns a typed timeout Result. On expiry the scheduler requests cancellation and drains the task's cooperative cleanup. A task returning Result produces a nested Result; choose explicitly which layer to propagate. Native work without cancellation checkpoints cannot be forcibly interrupted.
Complete example
Run this example locally with the installed CLI. The browser playground does not provide the host scheduler.
Await deadlines.
async fn load() -> int {
sleep 20ms
42
}
fn main() {
let result = await load() within 1s
print(result.unwrap())
}
Requires the Zolo CLI/host — open in the playground or run locally.
Rules and behavior
Parallel tasks and deadlines · Documentation
From a checkout of the repository:
zolo examples/features/await_deadlines.zolo
See also