Bernhard
07/29/2024, 9:20 AMsuspend fun stop(game: Game, weatherEffect: WeatherEffect) = coroutineScope {
val playlists = async {
findPlayingWeatherPlaylist(game)
.map { it.stopAll() }
.awaitAll()
}
val sounds = async {
findPlayingWeatherSound(game)
.forEach { it.typeSafeUpdate { playing = false } }
}
playlists.await()
sounds.await()
}
my general gutt feeling is that the foreach will not be executed in parallelCLOVIS
07/29/2024, 9:52 AMplaylists
and sounds
will be executed in parallel to each other.CLOVIS
07/29/2024, 9:53 AMstopAll
? It looks like it returns some kind of Deferred
, but shouldn't it be suspend
instead?Bernhard
07/29/2024, 9:56 AMBernhard
07/29/2024, 9:56 AMBernhard
07/29/2024, 9:57 AMCLOVIS
07/29/2024, 9:57 AMfindPlayingWeatherSound
?CLOVIS
07/29/2024, 9:59 AMList
, Sequence
or Flow
, then yeah, typeSafeUpdate
s are called sequentially to each other (but in parallel to everything happening to the playlists)Bernhard
07/29/2024, 10:10 AMBernhard
07/29/2024, 10:11 AMBernhard
07/29/2024, 10:11 AMCLOVIS
07/29/2024, 12:25 PMCLOVIS
07/29/2024, 12:26 PMfindPlayingWeatherSounds(game, effectsToStop)
.parMap { it.typeSafeUpdate { playing = false } }
but it's just a shortcut for the same code, it doesn't change anything.Zach Klippenstein (he/him) [MOD]
07/29/2024, 10:07 PM