Add link
This commit is contained in:
parent
60c744ca0c
commit
4114ec4efc
1 changed files with 1 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import kotlinx.coroutines.async
|
|||
import kotlinx.coroutines.awaitAll
|
||||
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 {
|
||||
map { async { f(it) } }.awaitAll()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue