Ansh Tyagi
11/09/2021, 7:31 PMBig Chungus
11/09/2021, 8:16 PMCLOVIS
11/11/2021, 9:44 PMCLOVIS
11/11/2021, 9:45 PMBig Chungus
11/11/2021, 9:46 PMBig Chungus
11/11/2021, 9:52 PMRichard Gomez
11/11/2021, 10:41 PMmyFlow.map {
async { methodToRun(it) }
}
.buffer()
.collect {
it.await()
}
Big Chungus
11/11/2021, 11:51 PMCLOVIS
11/12/2021, 8:18 AMsomeFlow
.toList()
.map { scope.async { ... } }
.asFlow()
.map { it.await() }
That would truly be parallel (depending on the scope of course), however the toList()
call forces all previous results to be known before the parallel operation starts.
With Java Streams (not multiplatform), you can write:
someList
.parallelStream()
.map { ... }
That will execute in parallel, however it is not coroutine-aware, so it might not be convenient depending on your use case.
There used to be a map
function on Channel (which would be the equivalent to Stream), but I recall it was removed, I don't remember why.DALDEI
12/13/2021, 3:21 PMCLOVIS
12/17/2021, 1:10 PM