Access to the coroutine's context


#1

It’s pretty easy to access to current Thread, however coroutine’s context isn’t accessible and it requires definition of variable.

Should be possible to inject the current coroutine context in any suspend function putting it in the last parameter of CSP, this make easily possible some utility like ThreadLocal.

A webserver can inject some authentication parameters in the context and make it available to all call chain.


#2

The plan is have a top-level val coroutineContext: CoroutineContext that is available from any suspend function: https://youtrack.jetbrains.com/issue/KT-17609