You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, kotlinx.coroutines provides primitives to work with thread locals.
The problem is that they are not quite safe and it is easy to accidentally forget them (#1016).
Moreover, sometimes it is necessary to know whether thread local is present in the context in order to do some action (e.g. probabilistic request tracing using thread locals, the case from Circlet).
In all cases, it is impossible to check whether thread local element is actually present in the context, and checking thread local itself is not an option, because it can have a stale or default value.
We can provide following extensions (similar to coroutineContext) to cover that cases and promote their usages in the documentation:
suspend fun TheadLocal<*>.ensurePresent(): Unit
suspend fun TheadLocal<*>.isPresent(): Boolean
suspend inline fun <T> ThreadLocal<T>.ifPresent(block: suspend (T) -> Unit) // Or R?
The text was updated successfully, but these errors were encountered:
Currently,
kotlinx.coroutines
provides primitives to work with thread locals.The problem is that they are not quite safe and it is easy to accidentally forget them (#1016).
Moreover, sometimes it is necessary to know whether thread local is present in the context in order to do some action (e.g. probabilistic request tracing using thread locals, the case from Circlet).
In all cases, it is impossible to check whether thread local element is actually present in the context, and checking thread local itself is not an option, because it can have a stale or default value.
We can provide following extensions (similar to
coroutineContext
) to cover that cases and promote their usages in the documentation:The text was updated successfully, but these errors were encountered: