W3cubDocs

/Kotlin

Package kotlin.coroutines.experimental.intrinsics

Platform and version requirements: Kotlin 1.1+

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

Properties

COROUTINE_SUSPENDED

val COROUTINE_SUSPENDED: Any

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

coroutineContext

suspend val coroutineContext: CoroutineContext

Continuation context of current coroutine.

Functions

createCoroutineUnchecked

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

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

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

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

intercepted

fun <T> Continuation<T>.intercepted(): Continuation<T>

Intercept continuation with ContinuationInterceptor.

startCoroutineUninterceptedOrReturn

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

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. This function is designed to be used from inside of suspendCoroutineOrReturn to resume the execution of suspended coroutine using a reference to the suspending function.

fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn(
    receiver: R, 
    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. This function is designed to be used from inside of suspendCoroutineOrReturn to resume the execution of suspended coroutine using a reference to the suspending function.

suspendCoroutineOrReturn

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

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

suspendCoroutineUninterceptedOrReturn

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

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

© 2010–2018 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines.experimental.intrinsics/index.html