Package-level declarations

Types

Link copied to clipboard

This Marker exists to prevent being able to call bind from install, and its derived methods. This is done to ensure correct usage of ResourceScope.

Link copied to clipboard
class CountDownLatch(initial: Long)

CountDownLatch allows for awaiting a given number of countdown signals. Models the behavior of java.util.concurrent.CountDownLatch in Kotlin with suspend.

Link copied to clipboard
class CyclicBarrier(val capacity: Int, barrierAction: () -> Unit = {})

A CyclicBarrier is a synchronization mechanism that allows a set of coroutines to wait for each other to reach a certain point before continuing execution. It is called a "cyclic" barrier because it can be reused after all coroutines have reached the barrier and released.

Link copied to clipboard
class CyclicBarrierCancellationException : CancellationException
Link copied to clipboard
sealed class ExitCase
Link copied to clipboard
sealed class Race3<out A, out B, out C>
Link copied to clipboard
typealias Resource<A> = suspend ResourceScope.() -> A

Resource models resource allocation and releasing. It is especially useful when multiple resources that depend on each other need to be acquired and later released in reverse order. The capability of installing resources is called ResourceScope, and Resource defines the value associating the acquisition step, and the finalizer. Resource allocates and releases resources in a safe way that co-operates with Structured Concurrency, and KotlinX Coroutines.

Link copied to clipboard
annotation class ResourceDSL
Link copied to clipboard
Link copied to clipboard
class ScopedRaiseAccumulate<Error>(raise: Raise<NonEmptyList<Error>>, scope: CoroutineScope) : CoroutineScope, RaiseAccumulate<Error>

Temporary intersection type, until we have context receivers

Link copied to clipboard
annotation class ScopeDSL

Functions

Link copied to clipboard
@DelicateCoroutinesApi
suspend fun <A> Resource<A>.allocate(): Pair<A, suspend (ExitCase) -> Unit>

Deconstruct Resource into an A and a release handler. The release action must always be called, if never called, then the resource A will leak. The release step is already made NonCancellable to guarantee correct invocation like Resource or bracketCase, and it will automatically rethrow, and compose, the exceptions as needed.

Link copied to clipboard
fun <A> Resource<A>.asFlow(): Flow<A>

Runs Resource.use and emits A of the resource

Link copied to clipboard
fun <A : AutoCloseable> autoCloseable(closingDispatcher: CoroutineDispatcher = IODispatcher, autoCloseable: suspend () -> A): Resource<A>
Link copied to clipboard
suspend fun <A : AutoCloseable> ResourceScope.autoCloseable(closingDispatcher: CoroutineDispatcher = IODispatcher, autoCloseable: suspend () -> A): A

Creates a Resource from an AutoCloseable, which uses AutoCloseable.close for releasing.

Link copied to clipboard
inline suspend fun <A, B> bracket(crossinline acquire: suspend () -> A, use: suspend (A) -> B, crossinline release: suspend (A) -> Unit): B

Describes a task with safe resource acquisition and release in the face of errors and interruption. It would be the equivalent of an async capable try/catch/finally statements in mainstream imperative languages for resource acquisition and release.

Link copied to clipboard
inline suspend fun <A, B> bracketCase(crossinline acquire: suspend () -> A, use: suspend (A) -> B, crossinline release: suspend (A, ExitCase) -> Unit): B

A way to safely acquire a resource and release in the face of errors and cancellation. It uses ExitCase to distinguish between different exit cases when releasing the acquired resource.

Link copied to clipboard
fun <A : Closeable> closeable(closingDispatcher: CoroutineDispatcher = Dispatchers.IO, closeable: suspend () -> A): Resource<A>
Link copied to clipboard
suspend fun <A : Closeable> ResourceScope.closeable(closingDispatcher: CoroutineDispatcher = Dispatchers.IO, closeable: suspend () -> A): A

Creates a Resource from an Closeable, which uses Closeable.close for releasing.

Link copied to clipboard
fun executor(timeout: Duration = Duration.INFINITE, closingDispatcher: CoroutineDispatcher = Dispatchers.IO, create: suspend () -> ExecutorService): Resource<ExecutorCoroutineDispatcher>
Link copied to clipboard
suspend fun ResourceScope.executor(timeout: Duration = Duration.INFINITE, closingDispatcher: CoroutineDispatcher = Dispatchers.IO, create: suspend () -> ExecutorService): ExecutorCoroutineDispatcher

Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.

Link copied to clipboard
fun fixedRate(periodInMillis: Long, dampen: Boolean = true, timeStamp: () -> ComparableTimeMark = { TimeSource.Monotonic.markNow() }): Flow<Unit>

fun fixedRate(period: Duration, dampen: Boolean = true, timeStamp: () -> ComparableTimeMark = { TimeSource.Monotonic.markNow() }): Flow<Unit>

Flow that emits Unit every period while taking into account how much time it takes downstream to consume the emission. If downstream takes longer to process than period than it immediately emits another Unit, if you set dampen to false it will send n = downstreamTime / period Unit elements immediately.

Link copied to clipboard
fun fixedThreadPoolContext(nThreads: Int, name: String): Resource<ExecutorCoroutineDispatcher>
Link copied to clipboard
suspend fun ResourceScope.fixedThreadPoolContext(nThreads: Int, name: String): ExecutorCoroutineDispatcher

Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.

Link copied to clipboard
inline suspend fun <A> guarantee(fa: suspend () -> A, crossinline finalizer: suspend () -> Unit): A

Guarantees execution of a given finalizer after fa regardless of success, error or cancellation.

Link copied to clipboard
inline suspend fun <A> guaranteeCase(fa: suspend () -> A, crossinline finalizer: suspend (ExitCase) -> Unit): A

Guarantees execution of a given finalizer after fa regardless of success, error or cancellation, allowing for differentiating between exit conditions with the ExitCase argument of the finalizer.

Link copied to clipboard
inline fun <A, B> Flow<A>.mapIndexed(crossinline f: suspend (index: Int, value: A) -> B): Flow<B>

Returns a flow containing the results of applying the given f function to each value and its index in the original flow.

Link copied to clipboard
fun <A> Flow<A>.metered(period: Long): Flow<A>

fun <A> Flow<A>.metered(period: Duration): Flow<A>

Flow that emits A every period while taking into account how much time it takes downstream to consume the emission. If downstream takes longer to process than period than it immediately emits another A.

Link copied to clipboard
inline suspend fun <A> onCancel(fa: suspend () -> A, crossinline onCancel: suspend () -> Unit): A

Registers an onCancel handler after fa. onCancel is guaranteed to be called in case of cancellation, otherwise it's ignored.

Link copied to clipboard
suspend fun <A, B> Iterable<A>.parMap(context: CoroutineContext = EmptyCoroutineContext, transform: suspend CoroutineScope.(A) -> B): List<B>
suspend fun <A, B> Iterable<A>.parMap(context: CoroutineContext = EmptyCoroutineContext, concurrency: Int, f: suspend CoroutineScope.(A) -> B): List<B>

@FlowPreview
@ExperimentalCoroutinesApi
inline fun <A, B> Flow<A>.parMap(concurrency: Int = DEFAULT_CONCURRENCY, crossinline transform: suspend CoroutineScope.(a: A) -> B): Flow<B>

Like map, but will evaluate transform in parallel, emitting the results downstream in the same order as the input stream. The number of concurrent effects is limited by concurrency.

Link copied to clipboard
suspend fun <A, B> Iterable<A>.parMapNotNull(context: CoroutineContext = EmptyCoroutineContext, transform: suspend CoroutineScope.(A) -> B?): List<B>
suspend fun <A, B> Iterable<A>.parMapNotNull(context: CoroutineContext = EmptyCoroutineContext, concurrency: Int, transform: suspend CoroutineScope.(A) -> B?): List<B>
Link copied to clipboard
@FlowPreview
@ExperimentalCoroutinesApi
inline fun <A, B> Flow<A>.parMapNotNullUnordered(concurrency: Int = DEFAULT_CONCURRENCY, crossinline transform: suspend (a: A) -> B?): Flow<B>

Like mapNotNull, but will evaluate effects in parallel, emitting the results downstream. The number of concurrent effects is limited by concurrency.

Link copied to clipboard
suspend fun <Error, A, B> Iterable<A>.parMapOrAccumulate(context: CoroutineContext = EmptyCoroutineContext, transform: suspend ScopedRaiseAccumulate<Error>.(A) -> B): Either<NonEmptyList<Error>, List<B>>
suspend fun <Error, A, B> Iterable<A>.parMapOrAccumulate(context: CoroutineContext = EmptyCoroutineContext, combine: (Error, Error) -> Error, transform: suspend ScopedRaiseAccumulate<Error>.(A) -> B): Either<Error, List<B>>
suspend fun <Error, A, B> Iterable<A>.parMapOrAccumulate(context: CoroutineContext = EmptyCoroutineContext, concurrency: Int, transform: suspend ScopedRaiseAccumulate<Error>.(A) -> B): Either<NonEmptyList<Error>, List<B>>
suspend fun <Error, A, B> Iterable<A>.parMapOrAccumulate(context: CoroutineContext = EmptyCoroutineContext, concurrency: Int, combine: (Error, Error) -> Error, transform: suspend ScopedRaiseAccumulate<Error>.(A) -> B): Either<Error, List<B>>
Link copied to clipboard
@FlowPreview
@ExperimentalCoroutinesApi
inline fun <A, B> Flow<A>.parMapUnordered(concurrency: Int = DEFAULT_CONCURRENCY, crossinline transform: suspend (a: A) -> B): Flow<B>

Like map, but will evaluate effects in parallel, emitting the results downstream. The number of concurrent effects is limited by concurrency.

Link copied to clipboard
inline suspend fun <A, B, C> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline f: suspend CoroutineScope.(A, B) -> C): C

Runs fa, fb in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline f: suspend CoroutineScope.(A, B) -> C): C

Runs fa, fb in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline f: suspend CoroutineScope.(A, B, C) -> D): D

Runs fa, fb, fc in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline f: suspend CoroutineScope.(A, B, C) -> D): D

Runs fa, fb, fc in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline f: suspend CoroutineScope.(A, B, C, D) -> E): E

Runs fa, fb, fc, fd in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline f: suspend CoroutineScope.(A, B, C, D) -> E): E

Runs fa, fb, fc, fd in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline f: suspend CoroutineScope.(A, B, C, D, E) -> F): F

Runs fa, fb, fc, fd, fe in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline f: suspend CoroutineScope.(A, B, C, D, E) -> F): F

Runs fa, fb, fc, fd, fe in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F) -> G): G

Runs fa, fb, fc, fd, fe, ff in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F) -> G): G

Runs fa, fb, fc, fd, fe, ff in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G) -> H): H

Runs fa, fb, fc, fd, fe, ff, fg in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G) -> H): H

Runs fa, fb, fc, fd, fe, ff, fg in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H, I> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline fh: suspend CoroutineScope.() -> H, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G, H) -> I): I

Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H, I> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline fh: suspend CoroutineScope.() -> H, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G, H) -> I): I

Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H, I, J> parZip(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline fh: suspend CoroutineScope.() -> H, crossinline fi: suspend CoroutineScope.() -> I, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G, H, I) -> J): J

Runs fa, fb, fc, fd, fe, ff, fg, fh, fi in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H, I, J> parZip(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline fh: suspend CoroutineScope.() -> H, crossinline fi: suspend CoroutineScope.() -> I, crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G, H, I) -> J): J

Runs fa, fb, fc, fd, fe, ff, fg, fh, fi in parallel on ctx and combines their results using the provided function.

Link copied to clipboard
inline suspend fun <E, A, B, C> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline transform: suspend CoroutineScope.(A, B) -> C): C
inline suspend fun <E, A, B, C> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline transform: suspend CoroutineScope.(A, B) -> C): C
inline suspend fun <E, A, B, C> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline transform: suspend CoroutineScope.(A, B) -> C): C
inline suspend fun <E, A, B, C, D> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline transform: suspend CoroutineScope.(A, B, C) -> D): D
inline suspend fun <E, A, B, C, D> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline transform: suspend CoroutineScope.(A, B, C) -> D): D
inline suspend fun <E, A, B, C> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline transform: suspend CoroutineScope.(A, B) -> C): C
inline suspend fun <E, A, B, C, D> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline transform: suspend CoroutineScope.(A, B, C) -> D): D
inline suspend fun <E, A, B, C, D, F> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F): F
inline suspend fun <E, A, B, C, D, F> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F): F
inline suspend fun <E, A, B, C, D> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline transform: suspend CoroutineScope.(A, B, C) -> D): D
inline suspend fun <E, A, B, C, D, F> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F): F
inline suspend fun <E, A, B, C, D, F, G> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G): G
inline suspend fun <E, A, B, C, D, F, G> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G): G
inline suspend fun <E, A, B, C, D, F> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline transform: suspend CoroutineScope.(A, B, C, D) -> F): F
inline suspend fun <E, A, B, C, D, F, G> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G): G
inline suspend fun <E, A, B, C, D, F, G, H> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H): H
inline suspend fun <E, A, B, C, D, F, G, H> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H): H
inline suspend fun <E, A, B, C, D, F, G> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline transform: suspend CoroutineScope.(A, B, C, D, F) -> G): G
inline suspend fun <E, A, B, C, D, F, G, H> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H): H
inline suspend fun <E, A, B, C, D, F, G, H, I> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I): I
inline suspend fun <E, A, B, C, D, F, G, H, I> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I): I
inline suspend fun <E, A, B, C, D, F, G, H> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G) -> H): H
inline suspend fun <E, A, B, C, D, F, G, H, I> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I): I
inline suspend fun <E, A, B, C, D, F, G, H, I, J> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J): J
inline suspend fun <E, A, B, C, D, F, G, H, I, J> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J): J
inline suspend fun <E, A, B, C, D, F, G, H, I> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H) -> I): I
inline suspend fun <E, A, B, C, D, F, G, H, I, J> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J): J
inline suspend fun <E, A, B, C, D, F, G, H, I, J, K> Raise<NonEmptyList<E>>.parZipOrAccumulate(crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline fj: suspend ScopedRaiseAccumulate<E>.() -> J, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K): K
inline suspend fun <E, A, B, C, D, F, G, H, I, J, K> Raise<E>.parZipOrAccumulate(crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline fj: suspend ScopedRaiseAccumulate<E>.() -> J, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K): K
inline suspend fun <E, A, B, C, D, F, G, H, I, J> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I) -> J): J
inline suspend fun <E, A, B, C, D, F, G, H, I, J, K> Raise<NonEmptyList<E>>.parZipOrAccumulate(context: CoroutineContext, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline fj: suspend ScopedRaiseAccumulate<E>.() -> J, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K): K
inline suspend fun <E, A, B, C, D, F, G, H, I, J, K> Raise<E>.parZipOrAccumulate(context: CoroutineContext, crossinline combine: (E, E) -> E, crossinline fa: suspend ScopedRaiseAccumulate<E>.() -> A, crossinline fb: suspend ScopedRaiseAccumulate<E>.() -> B, crossinline fc: suspend ScopedRaiseAccumulate<E>.() -> C, crossinline fd: suspend ScopedRaiseAccumulate<E>.() -> D, crossinline ff: suspend ScopedRaiseAccumulate<E>.() -> F, crossinline fg: suspend ScopedRaiseAccumulate<E>.() -> G, crossinline fh: suspend ScopedRaiseAccumulate<E>.() -> H, crossinline fi: suspend ScopedRaiseAccumulate<E>.() -> I, crossinline fj: suspend ScopedRaiseAccumulate<E>.() -> J, crossinline transform: suspend CoroutineScope.(A, B, C, D, F, G, H, I, J) -> K): K
Link copied to clipboard
inline suspend fun <A, B> raceN(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B): Either<A, B>

Races the participants fa, fb in parallel on the Dispatchers.Default. The winner of the race cancels the other participants. Cancelling the operation cancels all participants. An uncancellable participant will back-pressure the result of raceN.

inline suspend fun <A, B> raceN(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B): Either<A, B>

Races the participants fa, fb on the provided CoroutineContext. The winner of the race cancels the other participants. Cancelling the operation cancels all participants.

inline suspend fun <A, B, C> raceN(crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C): Race3<A, B, C>

Races the participants fa, fb&fc in parallel on the Dispatchers.Default. The winner of the race cancels the other participants. Cancelling the operation cancels all participants.

inline suspend fun <A, B, C> raceN(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C): Race3<A, B, C>

Races the participants fa, fb&fc on the provided CoroutineContext. The winner of the race cancels the other participants. Cancelling the operation cancels all participants.

Link copied to clipboard
fun <A> Flow<A>.repeat(): Flow<A>

Repeats the Flow forever

Link copied to clipboard
fun <A> resource(block: suspend ResourceScope.() -> A): Resource<A>

fun <A> resource(acquire: suspend () -> A, release: suspend (A, ExitCase) -> Unit): Resource<A>

Construct a Resource from an allocating function acquire and a release function release.

Link copied to clipboard
inline suspend fun <A> resourceScope(action: suspend ResourceScope.() -> A): A

The resourceScope function creates the ResourceScope instances, runs the user action while allocating the installed resources. upon ExitCase.Completed, ExitCase.Cancelled or ExitCase.Failure runs all the release finalizers.

Link copied to clipboard
fun singleThreadContext(name: String): Resource<ExecutorCoroutineDispatcher>
Link copied to clipboard
suspend fun ResourceScope.singleThreadContext(name: String): ExecutorCoroutineDispatcher

Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.

Link copied to clipboard
infix inline suspend fun <A, B> Resource<A>.use(f: suspend (A) -> B): B