Landerl Young
02/21/2019, 8:53 AMfun main() = runBlocking {
sth().await()
}
suspend fun sth() = coroutineScope {
async(start = CoroutineStart.LAZY) {
println("async execution")
}
}
The main function blocks forever, and the “async execution” is never printed. Could anyone give a hand, thanks.
😘gildor
02/21/2019, 8:54 AMgildor
02/21/2019, 8:55 AMcoroutineScope
function works: suspend until all child coroutines are finished, this is main use case of this functiongildor
02/21/2019, 8:56 AMLanderl Young
02/21/2019, 9:00 AMgildor
02/21/2019, 9:02 AMsth()
never returns because coroutineScope is suspended and not completedLanderl Young
02/21/2019, 9:03 AMgildor
02/21/2019, 9:03 AMLanderl Young
02/21/2019, 9:04 AMgildor
02/21/2019, 9:06 AMLanderl Young
02/21/2019, 9:14 AMpublic suspend inline val coroutineContext: CoroutineContext
for accessing context.gildor
02/21/2019, 9:24 AMcoroutineContext
is intrinsic that available in any suspend function