Created
May 7, 2023 19:47
-
-
Save omkar-tenkale/a1ea1f20133f2a60cc33340877bbc92d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.coroutines.Continuation | |
import kotlin.coroutines.CoroutineContext | |
import kotlin.coroutines.EmptyCoroutineContext | |
import kotlin.coroutines.intrinsics.createCoroutineUnintercepted | |
fun launch(block: suspend () -> Unit) { | |
val callback = object : Continuation<Unit> { | |
override val context: CoroutineContext = EmptyCoroutineContext | |
override fun resumeWith(result: Result<Unit>) {} | |
} | |
block.createCoroutineUnintercepted(callback).resumeWith(Result.success(Unit)) | |
} | |
fun main(){ | |
launch{ | |
greet() | |
} | |
} | |
suspend fun greet(){ | |
println("Hello World!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment