Skip to content

Instantly share code, notes, and snippets.

Last active February 22, 2021 21:09
What would you like to do?
abstract class Coroutine {
var isFinished: Boolean = false
private set
protected val state: State by lazy { State() }
protected fun resumeWith(result: Any) {
state.result = result
protected fun <T> restore(): T {
return state.result as T
protected fun finish() {
isFinished = true
protected class State(
var label: Int = 0,
var result: Any? = null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment