8.5 Structured concurrency
let (a, b) = scope {
let ha = spawn loadA()
let hb = spawn loadB()
(ha.join()?, hb.join()?)
}spawnis allowed only lexically insidescope { … }or with an explicits.spawn(…), wheres: &Scope.- Leaving a
scopewaits for all child tasks to finish. - The first error or panic of a child task that is not handled in the body cancels the other child tasks; the
scopereturns that error. The type of ascopeis the body type|Eof the child tasks| Panicked. - The node's background scope
node.backgroundlives until the node stops; the~>steps, the tails of pipelines (§10.6) and the tasksnode.background.spawn(…)run in it. When the node stops, the tasks there receive cancellation with draining.
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md