arrow-fx / arrow.fx.typeclasses / Concurrent

Concurrent

interface ~~Concurrent~~<F> : Async<F> Deprecated: The IO datatype and it’s related type classes will disappear in Arrow 0.13.0. All useful operations are offered directly over suspend functions by Arrow Fx Coroutines. https://arrow-kt.io/docs/fx/async/

Type class for async data types that are cancellable and can be started concurrently.

Properties

fx Entry point for monad bindings which enables for comprehensions. The underlying impl is based on coroutines. A coroutines is initiated and inside ConcurrentContinuation suspended yielding to Monad.flatMap. Once all the flatMap binds are completed the underlying monad is returned from the act of executing the coroutineopen val fx: ConcurrentFx<F>

Functions

bindingConcurrent Entry point for monad bindings which enables for comprehensions. The underlying impl is based on coroutines. A coroutines is initiated and inside ConcurrentCancellableContinuation suspended yielding to Monad.flatMap. Once all the flatMap binds are completed the underlying monad is returned from the act of executing the coroutineopen fun <B> bindingConcurrent(c: suspend ConcurrentContinuation<F, *>.() -> B): Kind<F, B>
cancelable open fun <A> ~~cancelable~~(k: ((Either<Throwable, A>) -> Unit) -> CancelToken<F>): Kind<F, A>
cancelableF open fun <A> ~~cancelableF~~(k: ((Either<Throwable, A>) -> Unit) -> Kind<F, CancelToken<F>>): Kind<F, A>
cancellable Creates a cancellable F instance that executes an asynchronous process on evaluation. Derived from async and bracketCase.open fun <A> cancellable(k: ((Either<Throwable, A>) -> Unit) -> CancelToken<F>): Kind<F, A>
cancellableF Builder to create a cancellable F instance that executes an asynchronous process on evaluation. Function derived from async and bracketCase.open fun <A> cancellableF(k: ((Either<Throwable, A>) -> Unit) -> Kind<F, CancelToken<F>>): Kind<F, A>
dispatchers abstract fun dispatchers(): Dispatchers<F>
fork Create a new F that upon execution starts the receiver F within a Fiber on this@fork.abstract fun <A> Kind<F, A>.fork(ctx: CoroutineContext): Kind<F, Fiber<F, A>>open fun <A> Kind<F, A>.fork(): Kind<F, Fiber<F, A>>
MVar Create a MVar or mutable variable structure to be used for thread-safe sharing, initialized to a value a.open fun <A> MVar(a: A): Kind<F, MVar<F, A>>
Create an empty MVar or mutable variable structure to be used for thread-safe sharing.open fun <A> MVar(): Kind<F, MVar<F, A>>
parApplicative open fun parApplicative(): Applicative<F>
open fun parApplicative(ctx: CoroutineContext): Applicative<F>
parMapN Map two tasks in parallel within a new F on ctx.open fun <A, B, C> parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, f: (Tuple2<A, B>) -> C): Kind<F, C>open fun <A, B, C> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, f: (A, B) -> C): Kind<F, C>
open fun <A, B, C, D> parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, f: (Tuple3<A, B, C>) -> D): Kind<F, D>
open fun <A, B, C, D> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, f: (A, B, C) -> D): Kind<F, D>
open fun <A, B, C, D, E> parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, f: (Tuple4<A, B, C, D>) -> E): Kind<F, E>
open fun <A, B, C, D, E> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, f: (A, B, C, D) -> E): Kind<F, E>
open fun <A, B, C, D, E, G> parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, f: (Tuple5<A, B, C, D, E>) -> G): Kind<F, G>
open fun <A, B, C, D, E, G> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, f: (A, B, C, D, E) -> G): Kind<F, G>
open fun <A, B, C, D, E, G, H> Concurrent<F>.parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, f: (Tuple6<A, B, C, D, E, G>) -> H): Kind<F, H>
open fun <A, B, C, D, E, G, H> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, f: (A, B, C, D, E, G) -> H): Kind<F, H>
open fun <F, A, B, C, D, E, G, H, I> Concurrent<F>.parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, f: (Tuple7<A, B, C, D, E, G, H>) -> I): Kind<F, I>
open fun <A, B, C, D, E, G, H, I> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, f: (A, B, C, D, E, G, H) -> I): Kind<F, I>
open fun <A, B, C, D, E, G, H, I, J> parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, fi: Kind<F, I>, f: (Tuple8<A, B, C, D, E, G, H, I>) -> J): Kind<F, J>
open fun <A, B, C, D, E, G, H, I, J> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, fi: Kind<F, I>, f: (A, B, C, D, E, G, H, I) -> J): Kind<F, J>
open fun <A, B, C, D, E, G, H, I, J, K> parMapN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, fi: Kind<F, I>, fj: Kind<F, J>, f: (Tuple9<A, B, C, D, E, G, H, I, J>) -> K): Kind<F, K>
open fun <A, B, C, D, E, G, H, I, J, K> CoroutineContext.~~parMapN~~(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, fi: Kind<F, I>, fj: Kind<F, J>, f: (A, B, C, D, E, G, H, I, J) -> K): Kind<F, K>
parSequence Runs all the F effects of the G structure to invert the structure from Kind<F, Kind<G, A>> to Kind<G, Kind<F, A>>.open fun <G, A> Kind<G, Kind<F, A>>.parSequence(TG: Traverse<G>, ctx: CoroutineContext): Kind<F, Kind<G, A>>open fun <G, A> Kind<G, Kind<F, A>>.parSequence(TG: Traverse<G>): Kind<F, Kind<G, A>>
open fun <A> Iterable<Kind<F, A>>.parSequence(ctx: CoroutineContext): Kind<F, List<A>>
open fun <A> Iterable<Kind<F, A>>.parSequence(): Kind<F, List<A>>
parTraverse Given a function which returns an F effect, run this effect in parallel for all the values in G.open fun <G, A, B> Kind<G, A>.parTraverse(ctx: CoroutineContext, TG: Traverse<G>, f: (A) -> Kind<F, B>): Kind<F, Kind<G, B>>open fun <G, A, B> Kind<G, A>.parTraverse(TG: Traverse<G>, f: (A) -> Kind<F, B>): Kind<F, Kind<G, B>>
open fun <A, B> Iterable<A>.parTraverse(ctx: CoroutineContext, f: (A) -> Kind<F, B>): Kind<F, List<B>>
open fun <A, B> Iterable<A>.parTraverse(f: (A) -> Kind<F, B>): Kind<F, List<B>>
parTupledN Map two tasks in parallel within a new F on ctx.open fun <A, B> parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>): Kind<F, Tuple2<A, B>>open fun <A, B, C> parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>): Kind<F, Tuple3<A, B, C>>
open fun <A, B, C, D> parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>): Kind<F, Tuple4<A, B, C, D>>
open fun <A, B, C, D, E> Concurrent<F>.parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>): Kind<F, Tuple5<A, B, C, D, E>>
open fun <A, B, C, D, E, G> Concurrent<F>.parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>): Kind<F, Tuple6<A, B, C, D, E, G>>
open fun <A, B, C, D, E, G, H> parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>): Kind<F, Tuple7<A, B, C, D, E, G, H>>
open fun <A, B, C, D, E, G, H, I> parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, fi: Kind<F, I>): Kind<F, Tuple8<A, B, C, D, E, G, H, I>>
open fun <A, B, C, D, E, G, H, I, J> parTupledN(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, fi: Kind<F, I>, fj: Kind<F, J>): Kind<F, Tuple9<A, B, C, D, E, G, H, I, J>>
Promise Create a pure Promise that is empty and can be filled exactly once.open fun <A> Promise(): Kind<F, Promise<F, A>>
raceN Race two tasks concurrently within a new F on this@raceN. At the end of the race it automatically cancels the loser.open fun <A, B> CoroutineContext.raceN(fa: Kind<F, A>, fb: Kind<F, B>): Kind<F, Race2<A, B>>open fun <A, B, C> CoroutineContext.raceN(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>): Kind<F, Race3<A, B, C>>
open fun <A, B, C, D> CoroutineContext.raceN(a: Kind<F, A>, b: Kind<F, B>, c: Kind<F, C>, d: Kind<F, D>): Kind<F, Race4<A, B, C, D>>
open fun <A, B, C, D, E> CoroutineContext.raceN(a: Kind<F, A>, b: Kind<F, B>, c: Kind<F, C>, d: Kind<F, D>, e: Kind<F, E>): Kind<F, Race5<A, B, C, D, E>>
open fun <A, B, C, D, E, G> CoroutineContext.raceN(a: Kind<F, A>, b: Kind<F, B>, c: Kind<F, C>, d: Kind<F, D>, e: Kind<F, E>, g: Kind<F, G>): Kind<F, Race6<A, B, C, D, E, G>>
open fun <A, B, C, D, E, G, H> CoroutineContext.raceN(a: Kind<F, A>, b: Kind<F, B>, c: Kind<F, C>, d: Kind<F, D>, e: Kind<F, E>, g: Kind<F, G>, h: Kind<F, H>): Kind<F, Race7<A, B, C, D, E, G, H>>
open fun <A, B, C, D, E, G, H, I> CoroutineContext.raceN(a: Kind<F, A>, b: Kind<F, B>, c: Kind<F, C>, d: Kind<F, D>, e: Kind<F, E>, g: Kind<F, G>, h: Kind<F, H>, i: Kind<F, I>): Kind<F, Race8<A, B, C, D, E, G, H, I>>
open fun <A, B, C, D, E, G, H, I, J> CoroutineContext.raceN(a: Kind<F, A>, b: Kind<F, B>, c: Kind<F, C>, d: Kind<F, D>, e: Kind<F, E>, g: Kind<F, G>, h: Kind<F, H>, i: Kind<F, I>, j: Kind<F, J>): Kind<F, Race9<A, B, C, D, E, G, H, I, J>>
racePair Race two tasks concurrently within a new F. Race results in a winner and the other, yet to finish task running in a Fiber.abstract fun <A, B> CoroutineContext.racePair(fa: Kind<F, A>, fb: Kind<F, B>): Kind<F, RacePair<F, A, B>>
raceTriple Race three tasks concurrently within a new F. Race results in a winner and the others, yet to finish task running in a Fiber.abstract fun <A, B, C> CoroutineContext.raceTriple(fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>): Kind<F, RaceTriple<F, A, B, C>>
Semaphore Create a pure Semaphore that can be used to control access in a concurrent system.open fun Semaphore(n: Long): Kind<F, Semaphore<F>>
sleep Sleeps for a given duration without blocking a thread.open fun sleep(duration: Duration): Kind<F, Unit>
timer open fun timer(): Timer<F>
waitFor Returns the result of this within the specified duration or the default value.open fun <A> Kind<F, A>.waitFor(duration: Duration, default: Kind<F, A>): Kind<F, A>
Returns the result of this within the specified duration or the raises a TimeoutException exception.open fun <A> Kind<F, A>.waitFor(duration: Duration): Kind<F, A>

Companion Object Functions

bounded open fun <A> Queue.Companion.bounded(capacity: Int): Kind<F, Queue<F, A>>
dropping open fun <A> Queue.Companion.dropping(capacity: Int): Kind<F, Queue<F, A>>
sliding open fun <A> Queue.Companion.sliding(capacity: Int): Kind<F, Queue<F, A>>
unbounded open fun <A> Queue.Companion.unbounded(): Kind<F, Queue<F, A>>

Extension Functions

parMapN fun <A, B, C, D, E, G, H> Concurrent<ForIO>.~~parMapN~~(ctx: CoroutineContext, fa: Kind<ForIO, A>, fb: Kind<ForIO, B>, fc: Kind<ForIO, C>, fd: Kind<ForIO, D>, fe: Kind<ForIO, E>, fg: Kind<ForIO, G>, f: (Tuple6<A, B, C, D, E, G>) -> H): IO<H>
fun <F, A, B, C, D, E, G, H, I> Concurrent<F>.~~parMapN~~(ctx: CoroutineContext, fa: Kind<F, A>, fb: Kind<F, B>, fc: Kind<F, C>, fd: Kind<F, D>, fe: Kind<F, E>, fg: Kind<F, G>, fh: Kind<F, H>, f: (Tuple7<A, B, C, D, E, G, H>) -> I): Kind<F, I>
parTupledN fun <A, B, C, D, E> Concurrent<ForIO>.~~parTupledN~~(ctx: CoroutineContext, fa: Kind<ForIO, A>, fb: Kind<ForIO, B>, fc: Kind<ForIO, C>, fd: Kind<ForIO, D>, fe: Kind<ForIO, E>): IO<Tuple5<A, B, C, D, E>>
fun <A, B, C, D, E, G> Concurrent<ForIO>.~~parTupledN~~(ctx: CoroutineContext, fa: Kind<ForIO, A>, fb: Kind<ForIO, B>, fc: Kind<ForIO, C>, fd: Kind<ForIO, D>, fe: Kind<ForIO, E>, fg: Kind<ForIO, G>): IO<Tuple6<A, B, C, D, E, G>>

Inheritors

ConcurrentContinuation open class ~~ConcurrentContinuation~~<F, A> : AsyncContinuation<F, A>, Concurrent<F>, ConcurrentSyntax<F>
ConcurrentSyntax interface ~~ConcurrentSyntax~~<F> : Concurrent<F>, AsyncSyntax<F>
IOConcurrent interface ~~IOConcurrent~~ : Concurrent<ForIO>, IOAsync
IODefaultConcurrent interface ~~IODefaultConcurrent~~ : Concurrent<ForIO>, IOConcurrent

Do you like Arrow?

Arrow Org
<