arrow-fx / arrow.fx / Queue

Queue

interface ~~Queue~~<F, A> : QueueOf<F, A>, Dequeue<F, A>, Enqueue<F, A> 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/

Lightweight Concurrent Queue for values of A.

A Queue can be used using 4 different back-pressure strategies:

  • bounded: Offering to a bounded queue at capacity will cause the fiber making the call to be suspended until the queue has space to receive the offer value

  • dropping: Offering to a dropping queue at capacity will cause the offered value to be discarded

  • sliding: Offering to a sliding queue at capacity will cause the value at the front of the queue to be discarded to make room for the offered value

  • unbounded: An unbounded queue has no notion of capacity and is bound only by exhausting the memory limits of the runtime

Types

BackpressureStrategy Internal model that represent the Queue strategiessealed class BackpressureStrategy

Functions

size Immediately returns the current size of values in the Queue. Can be a negative number when there are takers but no values available.abstract fun size(): Kind<F, Int>

Companion Object Functions

bounded Create a Queue with BackpressureStrategy.Bounded.fun <F, A> bounded(capacity: Int, CF: Concurrent<F>): Kind<F, Queue<F, A>>
dropping Create a Queue with BackpressureStrategy.Dropping.fun <F, A> dropping(capacity: Int, CF: Concurrent<F>): Kind<F, Queue<F, A>>
factory fun <F> factory(CF: Concurrent<F>): QueueFactory<F>
sliding Create a Queue with BackpressureStrategy.Sliding.fun <F, A> sliding(capacity: Int, CF: Concurrent<F>): Kind<F, Queue<F, A>>
unbounded Create a Queue with BackpressureStrategy.Unbounded.fun <F, A> unbounded(CF: Concurrent<F>): Kind<F, Queue<F, A>>

Companion Object Extension Functions

invariant fun <F> Queue.Companion.~~invariant~~(FR: Functor<F>): QueueInvariant<F>

Do you like Arrow?

Arrow Org
<