Package-level declarations

Select — expressions that perform multiple suspending operations simultaneously until one of them succeeds.

Types

Link copied to clipboard
interface SelectBuilder<in R>

Scope for select invocation.

Link copied to clipboard

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

Link copied to clipboard
interface SelectClause1<out Q> : SelectClause

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

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

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

Functions

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

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

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.

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.

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.

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

Loops while select expression returns true.