parallel For Each
suspend fun <T> Iterable<T>.parallelForEach(concurrency: Int = Int.MAX_VALUE, action: suspend (T) -> Unit)
Like forEach, but runs action for many elements at the same time. Returns when all are done.
staleEntries.parallelForEach(concurrency = 16) { cache.evict(it) }Content copied to clipboard
The rules for the limit, failures, cancellation and the copy of the elements are the same as for parallelMap.
Parameters
concurrency
the largest number of calls that run at the same time. At least 1. The default, Int.MAX_VALUE, means no limit.
Throws
if concurrency is less than 1.