Browse Source

Add link

feature/bma/flipper
Benoit Marty 2 years ago
parent
commit
4114ec4efc
  1. 1
      libraries/core/src/main/java/io/element/android/x/core/data/pmap.kt

1
libraries/core/src/main/java/io/element/android/x/core/data/pmap.kt

@ -4,6 +4,7 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.coroutineScope
// https://jivimberg.io/blog/2018/05/04/parallel-map-in-kotlin/
suspend fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> = coroutineScope { suspend fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> = coroutineScope {
map { async { f(it) } }.awaitAll() map { async { f(it) } }.awaitAll()
} }
Loading…
Cancel
Save