Extensions for kotlin.SuspendFunction1

startCoroutineCancellable

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

Use this function to start coroutine in a cancellable way, so that it can be cancelled while waiting to be dispatched.

startCoroutineUndispatched

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

Use this function to restart coroutine directly from inside of suspendCoroutine in the same context.