OxL Reference

8.5 Structured concurrency

oxl
let (a, b) = scope {
  let ha = spawn loadA()
  let hb = spawn loadB()
  (ha.join()?, hb.join()?)
}
  • spawn is allowed only lexically inside scope { … } or with an explicit s.spawn(…), where s: &Scope.
  • Leaving a scope waits 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 scope returns that error. The type of a scope is the body type | E of the child tasks | Panicked.
  • The node's background scope node.background lives until the node stops; the ~> steps, the tails of pipelines (§10.6) and the tasks node.background.spawn(…) run in it. When the node stops, the tasks there receive cancellation with draining.

spawn-outside-scope

See also

Source: docs/spec/oxl-standard.en.md