utilities.parallelCollectionOperations.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dokka-core Show documentation
Show all versions of dokka-core Show documentation
Dokka is an API documentation engine for Kotlin and Java, performing the same function as Javadoc for Java
package org.jetbrains.dokka.utilities
import kotlinx.coroutines.*
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 {
forEach { launch { f(it) } }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy