kotlin-flow-extensions / hu.akarnokd.kotlin.flow / ParallelFlow

ParallelFlow

interface ParallelFlow<out T>

Base interface for parallel stages in an operator

Properties

parallelism

abstract val parallelism: Int

Functions

collect

abstract suspend fun collect(vararg collectors: FlowCollector<T>): Unit

Extension Functions

concatMap

fun <T, R> ParallelFlow<T>.concatMap(mapper: suspend (T) -> Flow<R>): ParallelFlow<R>

Maps the upstream value on each rail onto a Flow and emits their values in order on the same rail.

filter

fun <T> ParallelFlow<T>.filter(predicate: suspend (T) -> Boolean): ParallelFlow<T>

Filters the values of the upstream in parallel.

map

fun <T, R> ParallelFlow<T>.map(mapper: suspend (T) -> R): ParallelFlow<R>

Maps the values of the upstream in parallel.

reduce

fun <T, R> ParallelFlow<T>.reduce(seed: suspend () -> R, combine: suspend (R, T) -> R): ParallelFlow<R>

Reduces the source items into a single value on each rail and emits those.

fun <T> ParallelFlow<T>.reduce(combine: suspend (T, T) -> T): Flow<T>

Reduce the values within the parallel rails and then reduce the rails to a single result value.

sequential

fun <T> ParallelFlow<T>.sequential(): Flow<T>

Consumes the parallel upstream and turns it into a sequential flow again.

transform

fun <T, R> ParallelFlow<T>.transform(callback: suspend FlowCollector<R>.(T) -> Unit): ParallelFlow<R>

Transform each upstream item into zero or more emits for the downstream in parallel.