https://kotlinlang.org logo
#coroutines
Title
# coroutines
l

littlelightcz

06/27/2018, 8:06 AM
Is there currently a way to call
withContext(CommonPool) { ... }
just like
withContext { ... }
? (similarly as async { } can be called on default pool) However just
withContext { ... }
might seem confusing, so maybe it would be nice to add some shorthand with a different name for this if there isn't anything like that already 🙂
g

gildor

06/27/2018, 8:18 AM
No, there is no such overload, why do you need this?
l

littlelightcz

06/27/2018, 6:09 PM
Well, I just wanted to do simple async {}.await(), but on a CommonPool, that is all 🙂. My app is quite small for now, so I don't mind running all coroutines in the default pool. However when I use the above, I get a (weak) warning that I should use the withContext for this, which requires me to specify the pool explicitly (unlike async). So maybe it could be nice to have some "default-pool" version of withContext function, but I have no idea what would be a good name for such a function, since this is a bit tricky 😄 . Maybe something like
withDefaultContext {}
or just
defaultContext {}
, but both maybe feel to be still too long 🙂.
6 Views