Reisishot
06/11/2019, 3:49 PM@ObsoleteCoroutinesApi
val LIMITED_PARALELLITY =
Executors.newFixedThreadPool(2 * Runtime.getRuntime().availableProcessors()).asCoroutineDispatcher()
@ObsoleteCoroutinesApi
fun <E> Iterable<E>.forEachLimitedParallel(callable: (E) -> Unit) = runBlocking {
forEach { launch(LIMITED_PARALELLITY) { callable(it) } }
}