class Selection
pub class Selection
A select as it is built: its cases, in the order they were added, and a timeout.
Methods
pub mut fn on<T>(c: Channel<T>, body: fn(?T) -> void throws Error): Selection
Adds a case, a receive from c, and returns the select. Its body gets what recv() would
give — the value, or null once c is closed and empty.
pub mut fn timeout(d: Duration, body: fn() -> void throws Error): Selection
Sets the timeout and returns the select: body runs when no case could go on before d
passed — with d of zero or less, when none can at once.
pub mut fn run(): void throws Error
Runs the select: the first case, in the order they were added, whose channel has a value or is closed runs at once. Else the running task waits on all of them, and the first channel to get a value or to close runs its case — or the timeout's body runs, once its time came first. One body runs, and only its case receives.
Errors
Throws what the chosen body throws; Cancelled in a cancelled task, where a cancel also ends the wait.