Extensions for kotlin.SuspendFunction0

startCoroutineCancellable

fun <T> (suspend () -> T).startCoroutineCancellable(
    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 <T> (suspend () -> T).startCoroutineUndispatched(
    completion: Continuation<T>
): Unit

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