SplitScript reference / future / race
future.race
Function
future.race<T>(operations: [async T]) -> async T
Waits for the first operation that completes.
Calling this function only captures the array. Polling the returned future polls the operations in array order on each runtime update, and the first ready value wins. When several operations become ready during the same update, the lowest array index wins. An empty array remains pending forever. After completion, this combinator stops polling the other operations; an operation retained elsewhere remains available through that shared handle.
Parameters
operations: Lazy operations with the same completion type.
Effects: requires an attached process, suspends, cancels when the process closes
Runtime behavior: available in suspending attachment code; suspends; cancels when the process closes
Examples
Race alternate module names
let executable = await future.race([
process.module("game.exe"),
process.module("game-demo.exe"),
])