how bad an idea is mutable state on a custom Corou...
# coroutines
g
how bad an idea is mutable state on a custom CoroutineContext element? like all the way bad?
I'm looking to use a thread local and to detect reentrancy from the same coroutine
l
If it's thread local, it's probably less risky. Just make sure worst cases are handled correctly and reasoning about code built upon this is not too hard.
e
If some code performs concurrent decomposition, then they all inherit this context element and may start to mutate it concurrently.
g
https://gist.github.com/Groostav/c0d6d7625db61045064b45b51a51b6d9 Its wrappedin an atomic reference. but it seems like Ive got a life-cycle missmatch. It could be "closed" and hang around on the object graph by virtue of a long-running co-routine for a long time. Hmm.