Merge branch 'develop' of https://github.com/vector-im/element-x-android-poc into develop
This commit is contained in:
commit
b1685ef6e2
1 changed files with 1 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue