how bad an idea is mutable state on a custom CoroutineContext element? like all the way bad?
groostav
07/26/2019, 7:53 AM
I'm looking to use a thread local and to detect reentrancy from the same coroutine
l
louiscad
07/26/2019, 7:56 AM
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
elizarov
07/26/2019, 10:20 AM
If some code performs concurrent decomposition, then they all inherit this context element and may start to mutate it concurrently.
g
groostav
07/26/2019, 7:49 PM
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.