async

.zn module

Cooperative, single-threaded task scheduler (the run-to-completion core of the concurrency model). import "async". No parallelism, no data races. Note: true mid-function await is deferred post-1.0 — a task runs to completion once started.

async.spawn(task: any)

Schedule a zero-arg function to run on the next drain.

async.pending() => int

Number of tasks waiting.

async.run()

Drain the queue FIFO until empty (including tasks spawned while draining).

import "async"
async.spawn(() => { println("task A") })
async.spawn(() => { println("task B") })
async.run()
On this page