block until given task is finished and return its result
Parameters
wait task :block :task
Attributes
| all |
|
wait for all tasks in the given block to settle and return their results in order |
| first |
|
wait for the first task in the given block to settle and return its result; the others are left running |
| any |
:integer |
wait for the first N tasks in the given block to settle and return their results in completion order |
| cancel |
|
with `.first` or `.any`: cancel the remaining (still-pending) tasks once enough have settled |
| timeout |
:integer, :quantity |
give up waiting after the given duration (ms by default; accepts time `:quantity` like `2:s`); returns an `:error` value on timeout |
Returns
Examples
copy
t: request.async "https://example.com" #[]
data: wait t
copy
; fan-out: settle all
tasks: map urls 'u -> request.async u #[]
results: wait.all tasks
copy
; settle for first N (completion order)
top3: wait.any: 3 tasks
top3: wait.any.cancel: 3 tasks ; abort remaining
Related