On `0.26.0` I see in the release notes that `Dispa...
# coroutines
d
On
0.26.0
I see in the release notes that
Dispatchers.Default
is now default dispatcher, but I had some existing code that was roughly
runBlocking { someList.map { async { <do stuff with 'it'> } }.map { it.await } }
that previously ran on
CommonPool
by default, but after the upgrade is constrained to the main thread. Guess I'm missing some detail around the structured concurrency changes...
If I change that to
async(Dispatchers.Default)
I get what I expect, but I don't follow why that wouldn't be the case by default?
b
async
now inherits the context of its parent (
runBlocking
). To get the same behavior you would use
GlobalScope.async
or use an explicit context (better)
or create your own scope (even better?)
d
Ah! Guess I'd better go and read the blog post and release notes more closely!