https://kotlinlang.org logo
#coroutines
Title
# coroutines
m

marcinmoskala

01/27/2020, 3:59 PM
Looking for a way to track the number of suspended coroutines in a context. My best guess for now is to make
ContinuationInterceptor
returning my custom continuation. Though cannot find an event on coroutine suspension.
interceptContinuation
is called much less often than
resumeWith
.
z

Zach Klippenstein (he/him) [MOD]

01/27/2020, 10:33 PM
There's no built-in hook for suspension - at the byte code level, a suspension is just a suspend function returning the suspended sentinel value instead of the actual return value. That said, I think the coroutine debug agent might let you derive some of the metrics you're looking for: https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-debug/README.md
m

marcinmoskala

01/28/2020, 8:20 AM
Looked at that, but this solutions seems too heavy and too young for a production code
8 Views