arrow-fx-coroutines / arrow.fx.coroutines

Package arrow.fx.coroutines

Types

Atomic Creates a AtomicRef with a initial value of A.interface Atomic<A>
AtomicBooleanW class AtomicBooleanW
AtomicIntW class AtomicIntW
AtomicRefW class AtomicRefW<A>
CancellableContinuation Type to constraint startCoroutineCancellable to the CancellableContinuation constructor.interface CancellableContinuation<A> : Continuation<A>
CancelToken Inline marker to mark a CancelToken, This allows for clearer APIs in functions that expect a CancelToken to be returned.class CancelToken
CircuitBreaker class CircuitBreaker
ConcurrentVar ConcurrentVar is a mutable concurrent safe variable which is either empty or contains a single value of type A. It behaves the same as a single element arrow.fx.coroutines.stream.concurrent.Queue. When trying to put or take, it’ll suspend when it’s respectively isEmpty or isNotEmpty.interface ConcurrentVar<A>
Disposable typealias Disposable = () -> Unit
Duration data class Duration
Environment Environment that can run suspend programs using startCoroutine and startCoroutineCancellable.interface Environment
ExitCase sealed class ExitCase
Fiber Fiber represents a pure value that contains a running suspend () -> A.interface Fiber<A>
IQueue Port of scala.collection.immutable.Queuedata class IQueue<A> : Iterable<A>
Platform object Platform
Promise When made, a Promise is empty. Until it is fulfilled, which can only happen once.interface Promise<A>
Race3 sealed class Race3<out A, out B, out C>
RacePair typealias RacePair<A, B> = Either<Pair<A, Fiber<B>>, Pair<Fiber<A>, B>>
RaceTriple sealed class RaceTriple<A, B, C>
Resource 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.sealed class Resource<out A>
Schedule Retrying and repeating effectssealed class Schedule<Input, Output>
Semaphore A counting Semaphore has a non-negative number of permits available. It’s used to track how many permits are in-use, and to automatically await a number of permits to become available.interface Semaphore
Use Marker for suspend () -> A to be marked as the Use action of a Resource. Offers a convenient DSL to use Resource for simple resources.class Use<A>

Extensions for External Classes

arrow.core.Either  
kotlin.collections.Iterable  
kotlin.coroutines.SuspendFunction0  
kotlin.Int  
kotlin.Long  
kotlin.Throwable  

Properties

ComputationPool A CoroutineContext to run non-blocking suspending code, all code that relies on blocking IO should prefer to use an unbounded IOPool.val ComputationPool: CoroutineContext
IOPool Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available, and uses the provided.val IOPool: CoroutineContext

Functions

bracket Meant for specifying tasks 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.suspend fun <A, B> bracket(acquire: suspend () -> A, use: suspend (A) -> B, release: suspend (A) -> Unit): B
bracketCase 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.suspend fun <A, B> bracketCase(acquire: suspend () -> A, use: suspend (A) -> B, release: suspend (A, ExitCase) -> Unit): B
cancelBoundary Inserts a cancellable boundarysuspend fun cancelBoundary(): Unit
cancellable Create a cancellable suspend function that executes an asynchronous process on evaluation. This combinator can be used to wrap callbacks or other similar impure code that requires cancellation code.suspend fun <A> cancellable(cb: ((Result<A>) -> Unit) -> CancelToken): A
CancellableContinuation Constructor for CancellableContinuationfun <A> CancellableContinuation(ctx: CoroutineContext = ComputationPool, resumeWith: (Result<A>) -> Unit): CancellableContinuation<A>
cancellableF Create a cancellable suspend function that executes an asynchronous process on evaluation. This combinator can be used to wrap callbacks or other similar impure code that requires cancellation code.suspend fun <A> cancellableF(cb: suspend ((Result<A>) -> Unit) -> CancelToken): A
evalOn Executes a task on context and comes back to the original CoroutineContext.suspend fun <T> evalOn(context: CoroutineContext, block: suspend () -> T): T
ForkAndForget Launches a new suspendable cancellable coroutine within a Fiber. You can Fiber.join or Fiber.cancel the computation.suspend fun <A> ForkAndForget(ctx: CoroutineContext = ComputationPool, f: suspend () -> A): Fiber<A>
ForkConnected Launches a new suspendable cancellable coroutine within a Fiber. It does so by connecting the created Fiber’s cancellation to the callers suspend scope. If the caller of ForkConnected gets cancelled, then this Fiber will also get cancelled.suspend fun <A> ForkConnected(ctx: CoroutineContext = ComputationPool, f: suspend () -> A): Fiber<A>
ForkScoped Launches a new suspendable cancellable coroutine within a Fiber. It does so by connecting the created Fiber’s cancellation to the provided interruptWhen. If the interruptWhen signal gets triggered, then this Fiber will get cancelled.suspend fun <A> ForkScoped(ctx: CoroutineContext = ComputationPool, interruptWhen: suspend () -> Unit, f: suspend () -> A): Fiber<A>
guarantee Guarantees execution of a given finalizer after fa regardless of success, error or cancellation.suspend fun <A> guarantee(fa: suspend () -> A, finalizer: suspend () -> Unit): A
guaranteeCase Guarantees execution of a given finalizer after fa regardless of success, error or cancellation., allowing for differentiating between exit conditions with to the ExitCase argument of the finalizer.suspend fun <A> guaranteeCase(fa: suspend () -> A, finalizer: suspend (ExitCase) -> Unit): A
never suspend fun <A> never(): A
onCancel Registers an onCancel handler after fa. onCancel is guaranteed to be called in case of cancellation, otherwise it’s ignored.suspend fun <A> onCancel(fa: suspend () -> A, onCancel: suspend () -> Unit): A
parMapN Parallel maps fa, fb in parallel on ComputationPool. Cancelling this operation cancels both operations running in parallel.suspend fun <A, B, C> parMapN(fa: suspend () -> A, fb: suspend () -> B, f: (A, B) -> C): C
Parallel maps fa, fb, fc in parallel on ComputationPool. Cancelling this operation cancels both operations running in parallel.suspend fun <A, B, C, D> parMapN(fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> C, f: (A, B, C) -> D): D
Parallel maps fa, fb on the provided CoroutineContext. Cancelling this operation cancels both tasks running in parallel.suspend fun <A, B, C> parMapN(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B, f: (A, B) -> C): C
Parallel maps fa, fb, fc on the provided CoroutineContext. Cancelling this operation cancels both tasks running in parallel.suspend fun <A, B, C, D> parMapN(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> C, f: (A, B, C) -> D): D
parTupledN Tuples fa, fb in parallel on ComputationPool. Cancelling this operation cancels both operations running in parallel.suspend fun <A, B> parTupledN(fa: suspend () -> A, fb: suspend () -> B): Pair<A, B>
Tuples fa, fb, fc in parallel on ComputationPool. Cancelling this operation cancels both tasks running in parallel.suspend fun <A, B, C> parTupledN(fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> C): Triple<A, B, C>
Tuples fa, fb on the provided CoroutineContext. Cancelling this operation cancels both tasks running in parallel.suspend fun <A, B> parTupledN(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B): Pair<A, B>
Tuples fa, fb & fc on the provided CoroutineContext. Cancelling this operation cancels both tasks running in parallel.suspend fun <A, B, C> parTupledN(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> C): Triple<A, B, C>
raceN Races the participants fa, fb in parallel on the ComputationPool. The winner of the race cancels the other participants, cancelling the operation cancels all participants. An uncancellable participants will back-pressure the result of raceN.suspend fun <A, B> raceN(fa: suspend () -> A, fb: suspend () -> 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.suspend fun <A, B> raceN(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B): Either<A, B>
Races the participants fa, fb & fc in parallel on the ComputationPool. The winner of the race cancels the other participants, cancelling the operation cancels all participants.suspend fun <A, B, C> raceN(fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> 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.suspend fun <A, B, C> raceN(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> C): Race3<A, B, C>
racePair suspend fun <A, B> racePair(fa: suspend () -> A, fb: suspend () -> B): RacePair<A, B>
Race two tasks concurrently within a new suspend fun. Race results in a winner and the other, yet to finish task running in a Fiber.suspend fun <A, B> racePair(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B): RacePair<A, B>
raceTriple suspend fun <A, B, C> raceTriple(fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> C): RaceTriple<A, B, C>
Race two tasks concurrently within a new suspend fun. Race results in a winner and the other, yet to finish task running in a Fiber.suspend fun <A, B, C> raceTriple(ctx: CoroutineContext, fa: suspend () -> A, fb: suspend () -> B, fc: suspend () -> C): RaceTriple<A, B, C>
release Composes a release action to a Resource.use action creating a Resource.infix fun <A> Use<A>.release(release: suspend (A) -> Unit): Resource<A>
releaseCase Composes a releaseCase action to a Resource.use action creating a Resource.infix fun <A> Use<A>.releaseCase(release: suspend (A, ExitCase) -> Unit): Resource<A>
repeat Run this effect once and, if it succeeded, decide using the passed policy if the effect should be repeated and if so, with how much delay. Returns the last output from the policy or raises an error if a repeat failed.suspend fun <A, B> repeat(schedule: Schedule<A, B>, fa: suspend () -> A): B
repeatOrElse Run this effect once and, if it succeeded, decide using the passed policy if the effect should be repeated and if so, with how much delay. Also offers a function to handle errors if they are encountered during repetition.suspend fun <A, B> repeatOrElse(schedule: Schedule<A, B>, fa: suspend () -> A, orElse: suspend (Throwable, B?) -> B): B
repeatOrElseEither Run this effect once and, if it succeeded, decide using the passed policy if the effect should be repeated and if so, with how much delay. Also offers a function to handle errors if they are encountered during repetition.suspend fun <A, B, C> repeatOrElseEither(schedule: Schedule<A, B>, fa: suspend () -> A, orElse: suspend (Throwable, B?) -> C): Either<C, B>
resource Marks an acquire operation as the Resource.use step of a Resource.fun <A> resource(acquire: suspend () -> A): Use<A>
retry Run an effect and, if it fails, decide using the passed 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.suspend fun <A, B> retry(schedule: Schedule<A, B>, fa: suspend () -> A): A
retryOrElse Run an effect and, if it fails, decide using the passed 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.suspend fun <A, B> retryOrElse(schedule: Schedule<A, B>, fa: suspend () -> A, orElse: suspend (Throwable, B) -> A): A
retryOrElseEither Run an effect and, if it fails, decide using the passed 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.suspend fun <A, B, C> retryOrElseEither(schedule: Schedule<A, B>, fa: suspend () -> A, orElse: suspend (Throwable, B) -> C): Either<C, A>
sleep Sleeps for a given duration without blocking a thread.suspend fun sleep(duration: Duration): Unit
timeOutOrNull Returns the result of fa within the specified duration or returns null.suspend fun <A> timeOutOrNull(duration: Duration, fa: suspend () -> A): A?
uncancellable Runs f in an uncancellable manner. If f gets cancelled, it will back-pressure the cancelling operation until finished.suspend fun <A> uncancellable(f: suspend () -> A): A
unit suspend fun unit(): Unit

Do you like Arrow?

Arrow Org
<