raceOf

suspend fun <T> raceOf(vararg blocks: suspend CoroutineScope.() -> T): T

Runs every block concurrently and returns the result of the first one to complete.

The remaining blocks are cancelled as soon as a winner exists. If the first block to complete fails, that failure is rethrown and the remaining blocks are cancelled.

Cancellation: cancelling the calling coroutine cancels every block. Losing blocks always receive cancellation; a winner is never cancelled by this function.

Throws