Last active
February 9, 2020 08:59
-
-
Save maxcruz/650b5de53272b00bf45cf6abd5d773e1 to your computer and use it in GitHub Desktop.
Run a map execution in parallel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suspend fun <I, O> Iterable<I>.parallelMap(function: suspend (I) -> O): List<O> = | |
coroutineScope { | |
map { async { function(it) } }.awaitAll() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment