Skip to main content
Spawned tasks live inside a scope. The scope owns the children and waits for them before the block exits. Start from Async and Await if you still need the suspension model.

Scoped Spawn

task.gather returns results in the order the handles were passed.

Linear Handles

TaskHandle[T, E] values are linear. Awaiting or joining a handle consumes it. The compiler rejects using the same handle twice.
This is the task version of Sifr’s ownership model: a handle represents a live child task, so there is exactly one path that observes it.

Select

Use task.select when two tasks race and the first result wins. The losing child is cancelled before the scope exits.

TaskGroup

Use task.TaskGroup when a group of tasks should run together and you need to observe individual results.
TaskGroup cancels unfinished siblings when any child fails. Do not rely on sibling work completing after another child has returned an error.

Next Steps

Cancellation and Timeouts

Bound the lifetime of async work and handle cancellation evidence.

Ownership Across Tasks

Learn what can cross a spawn boundary.