christophsturm
01/30/2021, 10:16 AMdeferredList.mapResolved{deferredResult -> ... }
christophsturm
01/30/2021, 10:50 AMsuspend fun bla(deferred: List<Deferred<Context>>) {
coroutineScope {
deferred.forEach {
launch {
val context = it.await()
println(
context.summary()
)
}
}
}
}
Arslan Armanuly
01/30/2021, 1:57 PMval singleThreadedContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
and then
withContext(singleThreadedContext) {
println(context.summary())
}
christophsturm
01/30/2021, 2:27 PMArslan Armanuly
01/30/2021, 3:49 PMArslan Armanuly
01/30/2021, 3:57 PMval mutex = Mutex()
mutex.withLock { /* code */ }
Arslan Armanuly
01/30/2021, 4:02 PMchristophsturm
01/30/2021, 5:36 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 5:36 PMif i do it like this, is there a way to be sure that my launch blocks don’t interrupt each other?
You mean you want the prints to be executed in the order of the list, regardless of which order the deferreds complete in?
christophsturm
01/30/2021, 5:39 PMchristophsturm
01/30/2021, 5:40 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 5:40 PMchristophsturm
01/30/2021, 5:41 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 5:41 PMchristophsturm
01/30/2021, 5:41 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 5:41 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 5:43 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 5:44 PMchristophsturm
01/30/2021, 5:45 PMchristophsturm
01/30/2021, 5:45 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 5:46 PMchristophsturm
01/30/2021, 5:48 PMchristophsturm
01/30/2021, 5:50 PMchristophsturm
01/30/2021, 5:50 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 8:05 PMZach Klippenstein (he/him) [MOD]
01/30/2021, 8:05 PMasSequence()
call on contextInfos
looks redundant though, List
has forEach
as wellchristophsturm
01/30/2021, 10:03 PM