Package kotlinx.coroutines.experimental.selects

Platform and version requirements: JVM

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

Types

SelectBuilder

interface SelectBuilder<in R>

Scope for select invocation.

SelectClause0

interface SelectClause0

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

SelectClause1

interface SelectClause1<out Q>

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

SelectClause2

interface SelectClause2<in P, out Q>

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

Functions

select

suspend fun <R> select(
    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

suspend fun <R> selectUnbiased(
    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

suspend fun whileSelect(
    builder: SelectBuilder<Boolean>.() -> Unit
): Unit

Loops while select expression returns true.