Skip to content

Instantly share code, notes, and snippets.

@maxcruz
Last active February 9, 2020 08:59
Show Gist options
  • Save maxcruz/650b5de53272b00bf45cf6abd5d773e1 to your computer and use it in GitHub Desktop.
Save maxcruz/650b5de53272b00bf45cf6abd5d773e1 to your computer and use it in GitHub Desktop.
Run a map execution in parallel
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