Is there a way to launch a coroutine in the same t...
# kotlin-native
s
Is there a way to launch a coroutine in the same thread as the current execution context? E.g.,
Copy code
var foo = "bar"
launch {
    foo = "baz" // no need to worry about frozen foo since both actions are taken on the same thread
}
b
runBlocking
s
I can’t use
runBlocking
because I need it to be asynchronous
b
then you'll have to make a CurrentThreadDispatcher or something to that effect. people have had success making a UIDispatcher, since main thread is often easy to locate on a give plaform
g
You can use Unconfined context, but careful, any suspend function which you call may switch dispatcher for you coroutine too. So the right solution is some custom dispatcher, like for UI