suspendCoroutine

Common
JVM
JS
Native
1.1
suspend inline fun <T> suspendCoroutine(
    crossinline block: (Continuation<T>) -> Unit
): T

Obtains the current continuation instance inside suspend functions and suspends currently running coroutine.

In this function both Continuation.resume and Continuation.resumeWithException can be used either synchronously in the same stack-frame where suspension function is run or asynchronously later in the same thread or from a different thread of execution. Repeated invocation of any resume function produces IllegalStateException.