Skip to content

Instantly share code, notes, and snippets.

@aleksandarzekovic
Last active September 15, 2022 20:48
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 aleksandarzekovic/d5e327a53106af29b65c65ebc1e0e2e5 to your computer and use it in GitHub Desktop.
Save aleksandarzekovic/d5e327a53106af29b65c65ebc1e0e2e5 to your computer and use it in GitHub Desktop.
/**
* Resumes the execution of the corresponding coroutine passing [value] as the return value of the last suspension point.
*/
@SinceKotlin("1.3")
@InlineOnly
public inline fun <T> Continuation<T>.resume(value: T): Unit =
resumeWith(Result.success(value))
/**
* Resumes the execution of the corresponding coroutine so that the [exception] is re-thrown right after the
* last suspension point.
*/
@SinceKotlin("1.3")
@InlineOnly
public inline fun <T> Continuation<T>.resumeWithException(exception: Throwable): Unit =
resumeWith(Result.failure(exception))
@Suppress("NOTHING_TO_INLINE")
internal inline fun Continuation<*>.resumeWithStackTrace(exception: Throwable) {
resumeWith(Result.failure(recoverStackTrace(exception, this)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment