Menu

Reference

Async

Classes

AggregateErrorSeveral task errors as one throwable.
CancellationTokenThe read-only half of cancellation.
CancelledExceptionRaised inside a task that was cancelled.
ChannelA typed pipe between tasks, in the style of a Go channel.
ChannelClosedExceptionThrown when sending to a closed channel.
ContextThe ambient view of the scope the calling task is in: cancellation, the effective deadline, and scoped values.
DeadlockExceptionThrown by async() when the loop runs out of work while tasks are still parked.
MutexA mutual-exclusion lock for a critical section that spans a suspend point.
OnceRun something exactly once, however many tasks ask for it.
PoolA bounded, FIFO pool of connections (or any objects), shared by tasks.
ReceivedOne receive from a channel, as an object.
SelectCaseOne arm of a select().
SelectedWhich select() case fired, and with what.
SemaphoreA counting semaphore: the bound on "do N of these at a time".
SettledHow one task turned out, when you asked for the outcome rather than the value.
TaskA running unit of async work: a green thread plus its settled state.
TaskGroupA structured-concurrency scope (a "nursery").
TimeoutExceptionThrown when a deadline elapses before the work finishes.

Functions

async()Run $main to completion on the async engine and return its value.
awaitAll()Wait for every task and return their results keyed by input position.
awaitAllSettled()Wait for every task and report how each one turned out.
awaitAny()Wait for the first successful task and return its value.
channel()Make a channel.
delay()Suspend the current task for $seconds without blocking the loop.
dump()A snapshot of the engine as text.
dumpOn()Print dump() to STDERR whenever one of $signals arrives.
failure()Where the last failure came from.
group()Open a child scope and return the body's value.
mapConcurrent()Map $fn over $items with at most $limit calls running at once.
mapSettled()mapConcurrent() that collects outcomes instead of failing fast.
readFile()Read a whole file in chunks, yielding to other tasks between them.
select()Wait for whichever case is ready first.
selectNow()The non-blocking select() (Go's default: arm).
selectWithin()select() with a deadline (Go's time.After arm).
shield()Hold cancellation back while $body runs.
shutdownOn()Graceful shutdown: on any of $signals, cancel the root scope.
spawn()Spawn a concurrent task into the scope open in the calling task and return a handle.
stats()Engine counters.
timeout()Run $body in a scope that must finish within $seconds.
watchdog()Name any task that holds the loop longer than $milliseconds.
writeFile()Write $data to a file in chunks, yielding to other tasks between them.