Skip to content

Instantly share code, notes, and snippets.

@omkar-tenkale
Created June 3, 2023 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omkar-tenkale/11e9ce73dccd7391381acd12f1163a60 to your computer and use it in GitHub Desktop.
Save omkar-tenkale/11e9ce73dccd7391381acd12f1163a60 to your computer and use it in GitHub Desktop.
suspend fun <T> suspendCoroutine(block: (Continuation<T>) -> Unit): T {
return suspendCoroutineUninterceptedOrReturn { cont ->
// block(cont)
val dispatchedContinuation = DispatcherContinuation(cont.context, cont)
block(dispatchedContinuation)
COROUTINE_SUSPENDED
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment