Slackbot
07/08/2018, 4:59 PMvoddan
07/08/2018, 5:01 PMasync
will use the default dispatcher (thread pool) for it to run. runBlocking
stays on the current threadHerko
07/08/2018, 5:03 PMasync
is called from will essentially be the same as runBlocking
. Doing it with async
will just incur more overhead? (in the context of the order of the calls as mentioned above)Herko
07/08/2018, 5:05 PMasync {...}.await()
when .await
follows the single async
call directly, but rather just call runBlocking {...}
in such a scenario?bj0
07/08/2018, 5:09 PMrunBlocking
blocks the thread, .await
suspends the thread, you never want to use runBlocking
from a coroutinebj0
07/08/2018, 5:09 PMbj0
07/08/2018, 5:09 PMrunBlocking
from non-coroutines to launch and wait for a coroutine (or many) to finishHerko
07/08/2018, 5:12 PMHerko
07/08/2018, 5:15 PM{...}
directly.bj0
07/08/2018, 5:20 PMasync
with an immediate await
is to change contexts (or suspend), but you can do that with withContext
gildor
07/09/2018, 12:39 AMgildor
07/09/2018, 12:40 AMasync{}.await()