Queue

abstract class Queue[F[_], A] extends QueueSource[F, A] with QueueSink[F, A]

A purely functional, concurrent data structure which allows insertion and retrieval of elements of type A in a first-in-first-out (FIFO) manner.

Depending on the type of queue constructed, the Queue#offer operation can block semantically until sufficient capacity in the queue becomes available.

The Queue#take operation semantically blocks when the queue is empty.

The Queue#tryOffer and Queue#tryTake allow for usecases which want to avoid fiber blocking a fiber.

Companion:
object
trait QueueSink[F, A]
trait QueueSource[F, A]
class Object
trait Matchable
class Any
trait Dequeue[F, A]
Queue[F, A]

Value members

Concrete methods

def mapK[G[_]](f: FunctionK[F, G]): Queue[G, A]

Modifies the context in which this queue is executed using the natural transformation f.

Modifies the context in which this queue is executed using the natural transformation f.

Returns:

a queue in the new context obtained by mapping the current one using f

Inherited methods

def offer(a: A): F[Unit]

Enqueues the given element at the back of the queue, possibly fiber blocking until sufficient capacity becomes available.

Enqueues the given element at the back of the queue, possibly fiber blocking until sufficient capacity becomes available.

Value parameters:
a

the element to be put at the back of the queue

Inherited from:
QueueSink
def size: F[Int]
Inherited from:
QueueSource
def take: F[A]

Dequeues an element from the front of the queue, possibly fiber blocking until an element becomes available.

Dequeues an element from the front of the queue, possibly fiber blocking until an element becomes available.

Inherited from:
QueueSource
def tryOffer(a: A): F[Boolean]

Attempts to enqueue the given element at the back of the queue without semantically blocking.

Attempts to enqueue the given element at the back of the queue without semantically blocking.

Value parameters:
a

the element to be put at the back of the queue

Returns:

an effect that describes whether the enqueuing of the given element succeeded without blocking

Inherited from:
QueueSink
def tryTake: F[Option[A]]

Attempts to dequeue an element from the front of the queue, if one is available without fiber blocking.

Attempts to dequeue an element from the front of the queue, if one is available without fiber blocking.

Returns:

an effect that describes whether the dequeueing of an element from the queue succeeded without blocking, with None denoting that no element was available

Inherited from:
QueueSource