Package kotlin.coroutines.intrinsics

Low-level building blocks for libraries that provide coroutine-based APIs.

Properties

Common
JVM
JS
Native
1.3

COROUTINE_SUSPENDED

This value is used as a return value of suspendCoroutineUninterceptedOrReturn block argument to state that the execution was suspended and will not return any result immediately.

val COROUTINE_SUSPENDED: Any

Functions

Common
JVM
JS
Native
1.3

createCoroutineUnintercepted

Creates unintercepted coroutine without receiver and with result type T. This function creates a new, fresh instance of suspendable computation every time it is invoked.

fun <T> (suspend () -> T).createCoroutineUnintercepted(
    completion: Continuation<T>
): Continuation<Unit>

Creates unintercepted coroutine with receiver type R and result type T. This function creates a new, fresh instance of suspendable computation every time it is invoked.

fun <R, T> (suspend R.() -> T).createCoroutineUnintercepted(
    receiver: R,
    completion: Continuation<T>
): Continuation<Unit>
Common
JVM
JS
Native
1.3

intercepted

Intercepts this continuation with ContinuationInterceptor.

fun <T> Continuation<T>.intercepted(): Continuation<T>
Common
JVM
JS
Native
1.3

startCoroutineUninterceptedOrReturn

Starts unintercepted coroutine without receiver and with result type T and executes it until its first suspension. Returns the result of the coroutine or throws its exception if it does not suspend or COROUTINE_SUSPENDED if it suspends. In the later case, the completion continuation is invoked when coroutine completes with result or exception.

fun <T> (suspend () -> T).startCoroutineUninterceptedOrReturn(
    completion: Continuation<T>
): Any?

Starts unintercepted coroutine with receiver type R and result type T and executes it until its first suspension. Returns the result of the coroutine or throws its exception if it does not suspend or COROUTINE_SUSPENDED if it suspends. In the later case, the completion continuation is invoked when coroutine completes with result or exception.

fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn(
    receiver: R,
    completion: Continuation<T>
): Any?
Common
JVM
JS
Native
1.3

suspendCoroutineUninterceptedOrReturn

Obtains the current continuation instance inside suspend functions and either suspends currently running coroutine or returns result immediately without suspension.

suspend fun <T> suspendCoroutineUninterceptedOrReturn(
    block: (Continuation<T>) -> Any?
): T