CoroutineStart

Defines start options for coroutines builders.

It is used in the start parameter of coroutine builder functions like launch and async to describe when and how the coroutine should be dispatched initially.

This parameter only affects how the coroutine behaves until the code of its body starts executing. After that, cancellability and dispatching are defined by the behavior of the invoked suspending functions.

The summary of coroutine start options is:

  • DEFAULT immediately schedules the coroutine for execution according to its context.

  • LAZY delays the moment of the initial dispatch until the result of the coroutine is needed.

  • ATOMIC prevents the coroutine from being cancelled before it starts, ensuring that its code will start executing in any case.

  • UNDISPATCHED immediately executes the coroutine until its first suspension point in the current thread.

Entries

Link copied to clipboard

Immediately schedules the coroutine for execution according to its context. This is usually the default option.

Link copied to clipboard

Starts the coroutine lazily, only when it is needed.

Link copied to clipboard

Atomically (i.e., in a non-cancellable way) schedules the coroutine for execution according to its context.

Link copied to clipboard

Immediately executes the coroutine until its first suspension point in the current thread.

Properties

Link copied to clipboard
val entries: EnumEntries<CoroutineStart>

Returns a representation of an immutable list of all enum entries, in the order they're declared.

Functions

Link copied to clipboard

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Link copied to clipboard

Returns an array containing the constants of this enum type, in the order they're declared.