kotlinx.coroutines
kotlinx.coroutines copied to clipboard
A prototype of ThreadContextElement on k/js and k/native
trafficstars
It's a mere copy/paste from jvm sources + 2 common tests to showcase how ThreadContextElement can be used (similar to Compose Runtime needs).
It's desirable to have some common CoroutineContext.Element similar to ThreadContextElement:
Specifically, such a CoroutineContext.Element would have 2 common things with ThreadContextElement: a function e.g. onResume(context: CoroutineContext): S, which is invoked before the coroutine in the specified context is resumed a function e.g. onSuspend(context: CoroutineContext, oldState: S), which is invoked after the coroutine in the specified context is suspended