Import std.concurrent.tasks
WhenAny
function
@PanicsAtCaller Public Function WhenAny<T>(tasks: Task<T>[]): Task<Int>
A Task of the index of the first of the tasks found done, whose result a Wait or an Await then
gives at once. At a tick of the scheduler it looks at them in their order, so of tasks done
before it looks, it's the first in the array, and one done after it looks, in that tick,
doesn't count.
Panics when there are none, since none would be done.
Examples
Local slow = TaskSource<Int>()
Local fast = TaskSource<Int>()
fast.Finish(7)
Expect(WhenAny([slow.Task, fast.Task]).Wait() == 1)
slow.Finish(0)function
@PanicsAtCaller Public Function WhenAny(tasks: Task[]): Task<Int>
A Task of the index of the first of the tasks to be done, as for tasks with results.
function
@PanicsAtCaller Public Function WhenAny<T, E: Error>(tasks: (Task<T> Throws E)[]): Task<Int>
A Task of the index of the first of the tasks found done, as for tasks that don't throw: one
that threw is done, and its Wait or Await then throws its error. Panics when there are none.
function
@PanicsAtCaller Public Function WhenAny<E: Error>(tasks: (Task Throws E)[]): Task<Int>
A Task of the index of the first of the tasks to be done, or to throw. Panics when there are
none.
Report an issue with this page or with FutureBlitz on GitHub.