CLOVIS
08/14/2024, 3:22 PMval a = async { … }
val b = async { … }
joinAll(a, b)
val a2 = a.getCompleted()
val b2 = b.getCompleted()
instead of
val a = async { … }
val b = async { … }
val a2 = a.await()
val b2 = b.await()
?
I believe they are identical (at least in terms of concurrent execution and cancellation behavior).kevin.cianfarini
08/14/2024, 3:26 PMawaitAll
has a specific implementation that’s not just forEach { it.await() }
, and that presumably has performance benefits associated with it. https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/common/src/Await.kt#L60-L120kevin.cianfarini
08/14/2024, 3:27 PMjoinAll
is just a forEach loop thoughCLOVIS
08/14/2024, 3:28 PMCoroutineStart.LAZY
? If you use a basic for-loop, they will end up being sequential 🤔
But that's not used in my example, and even then, it wouldn't make a differencekevin.cianfarini
08/14/2024, 3:59 PMCLOVIS
08/14/2024, 4:01 PMkevin.cianfarini
08/15/2024, 11:50 AMCLOVIS
08/15/2024, 12:28 PMjoinAll
doesn't have all the things we mentioned that awaitAll
has.kevin.cianfarini
08/15/2024, 1:23 PMDeferred.join
wouldn't throw an exceptional result, but it looks like I'm wrong! If that's not the case I don't see a difference between these two.