parallelMap
suspend fun <T, R> Iterable<T>.parallelMap(concurrency: Int = Int.MAX_VALUE, transform: suspend (T) -> R): List<R>
Transforms every element concurrently and returns the results in the original order.
At most concurrency transforms run at the same time, limited by a Semaphore. The first failing transform cancels the remaining work and its failure is rethrown to the caller.
Cancellation: cancelling the calling coroutine cancels every in-flight transform before rethrowing.
Parameters
concurrency
the maximum number of concurrent transforms, at least 1.
Throws
if concurrency is less than 1.