OxL Reference

8.3 Task

  • Task<T, E> is a lazy computation. It is created in the positions of §6.3 or explicitly by Task.of { … }.
  • A task is movable and single-use: exactly one operation consumes it — await, spawn, a combinator or the start of a chain.
  • spawn t (only inside a scope, §8.5) starts the task and returns a Handle<T, E>: h.join() -> T | E | Cancelled, h.cancel().
CombinatorResultBehaviour
all(t1, …, tn)(T1, …, Tn) | E1 | … | Enin parallel; the first error cancels the others
race(t1, …, tn)T1 | … | Tn | E1 | … | Enthe first to finish (success or error), the others are cancelled
any(t1, …, tn)T1 | … | Tn | AllFailedthe first success; AllFailed contains all errors
all(list)List<T> | Efor a list of tasks of one type

The parameters of the combinators are declared lazy, therefore all(Users.get(1), Orders.list(1)) does not execute the calls before the combinator starts.

task-reuse

See also

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