Exerosis
06/06/2022, 4:05 AMZach Klippenstein (he/him) [MOD]
06/06/2022, 4:17 AMExerosis
06/06/2022, 4:27 AMclass DelegateInterceptor(
private val delegate: ContinuationInterceptor
) : ContinuationInterceptor by delegate {
companion object : Key<DelegateInterceptor>
override val key = DelegateInterceptor
override fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T> {
println("Intercepting continuation")
return delegate.interceptContinuation(continuation)
}
override fun releaseInterceptedContinuation(continuation: Continuation<*>) {
println("Relasing continuation")
delegate.releaseInterceptedContinuation(continuation)
}
override fun toString() = "DelegateInterceptor[$delegate]"
}
Humm if I do this:
fun main() = runBlocking {
withContext(DelegateInterceptor(coroutineContext[ContinuationInterceptor]!!)) {
...
}
}
It never seems to get called, but I'm not sure how else to get the runBlocking context hereZach Klippenstein (he/him) [MOD]
06/06/2022, 4:46 AMContinuationInterceptor.Key
?Exerosis
06/06/2022, 4:51 AMrunBlocking(SomeInterceptorWithAKey()) {
println(coroutineContext[ContinuationInterceptor])
}
seems to print SomeInterceptorWithAKey