Package kotlinx.coroutines.selects

Select expression to perform multiple suspending operations simultaneously until one of them succeeds.

Types

SelectBuilder
Link copied to clipboard
interface SelectBuilder<in R>

Scope for select invocation.

SelectClause0
Link copied to clipboard
interface SelectClause0

Clause for select expression without additional parameters that does not select any value.

SelectClause1
Link copied to clipboard
interface SelectClause1<out Q>

Clause for select expression without additional parameters that selects value of type Q.

SelectClause2
Link copied to clipboard
interface SelectClause2<in P, out Q>

Clause for select expression with additional parameter of type P that selects value of type Q.

Functions

onTimeout
Link copied to clipboard
fun <R> SelectBuilder<R>.onTimeout(timeout: Duration, block: suspend () -> R)

Clause that selects the given block after the specified timeout passes. If timeout is negative or zero, block is selected immediately.

select
Link copied to clipboard
inline suspend fun <R> select(crossinline builder: SelectBuilder<R>.() -> Unit): R

Waits for the result of multiple suspending functions simultaneously, which are specified using clauses in the builder scope of this select invocation. The caller is suspended until one of the clauses is either selected or fails.

selectUnbiased
Link copied to clipboard
inline suspend fun <R> selectUnbiased(crossinline builder: SelectBuilder<R>.() -> Unit): R

Waits for the result of multiple suspending functions simultaneously like select, but in an unbiased way when multiple clauses are selectable at the same time.

whileSelect
Link copied to clipboard
inline suspend fun whileSelect(crossinline builder: SelectBuilder<Boolean>.() -> Unit)

Loops while select expression returns true.