Exerosis
03/15/2022, 4:49 AMclass Test {
val continuation = Continuation<Unit>(EmptyCoroutineContext) {
}
suspend fun testFire() = suspendCoroutineUninterceptedOrReturn<Unit> { cont ->
println(continuation)
println(cont)
println(continuation == cont)
}
fun testMain() {
val action: suspend () -> (Unit) = {
testFire()
}
action.startCoroutineUninterceptedOrReturn(continuation)
}
}
Why does this not not print the same thing twice and then true? IK it's significantly stupid but it still wasn't what I was expecting.
And more generally is there a way to (safely) inject some sort of identifier into a continuation that can be picked up later? I assume Context is the right thing to use but I don't want to like overwrite any other context like job.Nick Allen
03/15/2022, 5:14 AMCoroutineContext
is designed for. You can create your own keys and elements and then “inject” them like a CoroutineName
or CoroutineDispatcher
.