package org.jetbrains.dokka.utilities
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
suspend inline fun Iterable.parallelMap(crossinline f: suspend (A) -> B): List = coroutineScope {
map { async { f(it) } }.awaitAll()
}
suspend inline fun Iterable.parallelMapNotNull(crossinline f: suspend (A) -> B?): List = coroutineScope {
map { async { f(it) } }.awaitAll().filterNotNull()
}
suspend inline fun Iterable.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope {
map { async { f(it) } }.awaitAll()
}