CoroutineStart

enum class CoroutineStart (source)

Defines start option for coroutines builders. It is used in start parameter of launch, async, and other coroutine builder functions.

The summary of coroutine start options is:

Enum Values

DEFAULT

Default – immediately schedules coroutine for execution according to its context.

LAZY

Starts coroutine lazily, only when it is needed.

ATOMIC

Atomically (in non-cancellable way) schedules coroutine for execution according to its context. This is similar to DEFAULT, but the coroutine cannot be cancelled before it starts executing.

UNDISPATCHED

Immediately executes coroutine until its first suspension point in the current thread as if it the coroutine was started using Unconfined dispatcher. However, when coroutine is resumed from suspension it is dispatched according to the CoroutineDispatcher in its context.

Properties

isLazy

val isLazy: Boolean

Returns true when LAZY.

Functions

invoke

operator fun <T> invoke(
    block: suspend () -> T,
    completion: Continuation<T>
): Unit

Starts the corresponding block as a coroutine with this coroutine start strategy.

operator fun <R, T> invoke(
    block: suspend R.() -> T,
    receiver: R,
    completion: Continuation<T>
): Unit

Starts the corresponding block with receiver as a coroutine with this coroutine start strategy.