arrow-fx-coroutines / arrow.fx.coroutines.stream.concurrent / Queue

Queue

interface ~~Queue~~<A> : Enqueue<A>, Dequeue1<A>, Dequeue<A> Deprecated: Stream is deprecated in favor of Flow. Use Channel

A queue of elements. Operations are all nonblocking in their implementations, but may be ‘semantically’ blocking. For instance, a queue may have a bound on its size, in which case enqueuing may block (be delayed asynchronously) until there is an offsetting dequeue.

Functions

dequeueChunk1 Dequeues one Chunk[A] with no more than maxSize elements. Completes once one is ready.abstract suspend fun dequeueChunk1(maxSize: Int): Chunk<A>
imap Returns an alternate view of this Queue where its elements are of type B, given two functions, (A) -> B and (B) -> A.open fun <B> imap(f: (A) -> B, g: (B) -> A): Queue<B>
tryDequeueChunk1 Tries to dequeue a single chunk of no more than max size elements. Unlike dequeueChunk1, this method does not semantically block until a chunk is available - instead, None is returned immediately.abstract suspend fun tryDequeueChunk1(maxSize: Int): Option<Chunk<A>>

Companion Object Functions

bounded Creates a FIFO queue with the specified size bound.suspend fun <A> bounded(maxSize: Int): Queue<A>
dropping Creates a queue which stores the first maxSize enqueued elements and which never blocks on enqueue.suspend fun <A> dropping(maxSize: Int): Queue<A>
fairBounded Created a bounded queue that distributed always at max fairSize elements to any subscriber.suspend fun <A> fairBounded(maxSize: Int, fairSize: Int): Queue<A>
fairUnbounded Creates an unbounded FIFO queue that distributed always at max fairSize elements to any subscriber.suspend fun <A> fairUnbounded(fairSize: Int): Queue<A>
sliding Creates a queue which stores the last maxSize enqueued elements and which never blocks on enqueue.suspend fun <A> sliding(maxSize: Int): Queue<A>
synchronous Creates a Queue in which each enqueue operation must wait for a corresponding dequeue operation, and vice versa. In other words, dequeue and enqueue need to shake hands, or meet, before the value is successfully passed along. Works like functional suspending version java.util.concurrent.SynchronousQueue.suspend fun <A> synchronous(): Queue<A>
synchronousNoneTerminated Like synchronous, except that any enqueue of None will never block and cancels any dequeue operation.suspend fun <A> synchronousNoneTerminated(): NoneTerminatedQueue<A>
unbounded Creates a FIFO queue with no size bound.suspend fun <A> unbounded(): Queue<A>
unsafeBounded fun <A> unsafeBounded(maxSize: Int): Queue<A>
unsafeDropping fun <A> unsafeDropping(maxSize: Int): Queue<A>
unsafeFairBounded fun <A> unsafeFairBounded(maxSize: Int, fairSize: Int): Queue<A>
unsafeFairUnbounded fun <A> unsafeFairUnbounded(fairSize: Int): Queue<A>
unsafeSliding fun <A> unsafeSliding(maxSize: Int): Queue<A>
unsafeSynchronous fun <A> unsafeSynchronous(): Queue<A>
unsafeSynchronousNoneTerminated fun <A> unsafeSynchronousNoneTerminated(): NoneTerminatedQueue<A>
unsafeUnbounded fun <A> unsafeUnbounded(): Queue<A>

Do you like Arrow?

Arrow Org
<