https://kotlinlang.org logo
Title
b

Brian Carr

03/03/2021, 8:15 PM
Hello! I asked this over in #getting-started and it was suggsted that ask ask over here.
m

mng

03/04/2021, 3:52 AM
1. Maybe i'm misunderstanding but a
suspend
function can only ultimately be called using a CoroutineScope from a function that is not
suspend
b

Brian Carr

03/04/2021, 3:55 AM
I think as of the release of 1.4.3, my question might be irrelevant. I’m writing tests to confirm right now. However, my base problem was that I had ThreadLocal storage being accessed as coroutineContext elements. I had a safeGet method which checked if the key was in the context before calling get() on the ThreadLocal. My goal was to try to prevent calls to ThreadLocal.get() from inside a coroutineScope
it’s still bad to call ThreadLocal.get() if no parent scope/context has had the contextElement added, but it’s less risky than it was before today’s release.
though it appears that ThreadLocal.remove() behaves the same way as ThreadLocal.set() does with today’s release.