Package-level declarations

Types

Link copied to clipboard
interface Atomic<A>

An Atomic with an initial value of A.

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
sealed class ExitCase
Link copied to clipboard
sealed class Race3<out A, out B, out C>
Link copied to clipboard
sealed class Resource<out 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

Temporary intersection type, until we have context receivers

Functions

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 = Dispatchers.IO, autoCloseable: suspend () -> A): Resource<A>
Link copied to clipboard
suspend fun <A : AutoCloseable> ResourceScope.autoCloseable(closingDispatcher: CoroutineDispatcher = Dispatchers.IO, 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(period: Long, dampen: Boolean = true, timeStampInMillis: () -> Long = { timeInMillis() }): 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.

fun fixedRate(period: Duration, dampen: Boolean = true, timeStampInMillis: () -> Long = { timeInMillis() }): Flow<Unit>
Link copied to clipboard
Link copied to clipboard

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>

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>

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
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
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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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 f: 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
infix fun <A> Resource<A>.release(release: suspend (A) -> Unit): Resource<A>

Composes a release action to a Resource.use action creating a Resource.

Link copied to clipboard
infix fun <A> Resource<A>.releaseCase(release: suspend (A, ExitCase) -> Unit): Resource<A>

Composes a releaseCase action to a Resource.use action creating a Resource.

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

Repeats the Flow forever

Link copied to clipboard
fun <A> resource(action: suspend ResourceScope.() -> A): Resource<A>
fun <A> resource(acquire: suspend () -> A, release: suspend (A, ExitCase) -> Unit): Resource<A>
Link copied to clipboard
suspend fun <A> resourceScope(action: suspend ResourceScope.() -> A): A
Link copied to clipboard
suspend fun <A, B> Schedule<Throwable, B>.retry(fa: suspend () -> A): A

Runs an effect and, if it fails, decide using the provided policy if the effect should be retried and if so, with how much delay. Returns the result of the effect if if it was successful or re-raises the last error encountered when the schedule ends.

Link copied to clipboard
suspend fun <A, B> Schedule<Throwable, B>.retryOrElse(fa: suspend () -> A, orElse: suspend (Throwable, B) -> A): A

Runs an effect and, if it fails, decide using the provided policy if the effect should be retried and if so, with how much delay. Also offers a function to handle errors if they are encountered during retrial.

Link copied to clipboard
suspend fun <A, B, C> Schedule<Throwable, B>.retryOrElseEither(fa: suspend () -> A, orElse: suspend (Throwable, B) -> C): Either<C, A>

Runs an effect and, if it fails, decide using the provided policy if the effect should be retried and if so, with how much delay. Also offers a function to handle errors if they are encountered during retrial.

Link copied to clipboard

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
expect fun timeInMillis(): Long

Gets current system time in milliseconds since certain moment in the past, only delta between two subsequent calls makes sense.

actual fun timeInMillis(): Long
actual fun timeInMillis(): Long
actual fun timeInMillis(): Long