Chantry Cargill
02/21/2020, 2:12 PM@GetMapping("/things")
suspend fun getThings() = coroutineScope {
val thing = async {
suspendingCall()
}
val anotherThing = async {
suspendingCallAgain()
}
listOf(thing.await(), anotherThing.await())
}
louiscad
02/21/2020, 2:31 PMDefault
be the default is probably the safest.Chantry Cargill
02/21/2020, 2:41 PMZach Klippenstein (he/him) [MOD]
02/21/2020, 2:42 PMZach Klippenstein (he/him) [MOD]
02/21/2020, 2:50 PMChantry Cargill
02/21/2020, 3:03 PMZach Klippenstein (he/him) [MOD]
02/21/2020, 3:34 PMasync
is an extension on CoroutineScope
, it automatically inherits everything from the calling scope.
The behavior you were initially expecting is what you got if you used GlobalScope.async
, which is strongly discouraged for a number of reasons, including this.Chantry Cargill
02/21/2020, 3:35 PM