8.3 Task
Task<T, E>is a lazy computation. It is created in the positions of §6.3 or explicitly byTask.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 ascope, §8.5) starts the task and returns aHandle<T, E>:h.join() -> T | E | Cancelled,h.cancel().
| Combinator | Result | Behaviour |
|---|---|---|
all(t1, …, tn) | (T1, …, Tn) | E1 | … | En | in parallel; the first error cancels the others |
race(t1, …, tn) | T1 | … | Tn | E1 | … | En | the first to finish (success or error), the others are cancelled |
any(t1, …, tn) | T1 | … | Tn | AllFailed | the first success; AllFailed contains all errors |
all(list) | List<T> | E | for 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.
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md