BoundedQueue

cats.effect.std.unsafe.BoundedQueue
See theBoundedQueue companion object
trait BoundedQueue[F[_], A] extends Queue[F, A], BoundedQueueSink[F, A]

A Queue which supports a side-effecting variant of tryOffer, allowing impure code to add elements to the queue without having to indirect through something like Dispatcher. Note that a side-effecting variant of offer is impossible without hard-blocking a thread (when the queue is full), and thus is not supported by this API. For a variant of the same queue which supports a side-effecting offer, see UnboundedQueue.

Attributes

See also
Companion
object
Source
BoundedQueue.scala
Graph
Supertypes
trait BoundedQueueSink[F, A]
class Queue[F, A]
trait QueueSink[F, A]
trait QueueSource[F, A]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait UnboundedQueue[F, A]

Members list

Value members

Inherited 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.

Attributes

Returns

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

Inherited from:
Queue
Source
Queue.scala
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

Attributes

Inherited from:
QueueSink
Source
QueueSink.scala
def size: F[Int]

Attributes

Inherited from:
QueueSource
Source
QueueSource.scala
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.

Attributes

Inherited from:
QueueSource
Source
QueueSource.scala
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

Attributes

Returns

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

Inherited from:
QueueSink
Source
QueueSink.scala
def tryOfferN(list: List[A])(implicit F: Monad[F]): F[List[A]]

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

Attempts to enqueue the given elements at the back of the queue without semantically blocking. If an item in the list cannot be enqueued, the remaining elements will be returned. This is a convenience method that recursively runs tryOffer and does not offer any additional performance benefits.

Value parameters

list

the elements to be put at the back of the queue

Attributes

Returns

an effect that contains the remaining valus that could not be offered.

Inherited from:
QueueSink
Source
QueueSink.scala
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.

Attributes

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
Source
QueueSource.scala
def tryTakeN(maxN: Option[Int])(implicit F: Monad[F]): F[List[A]]

Attempts to dequeue elements from the front of the queue, if they are available without semantically blocking.

Attempts to dequeue elements from the front of the queue, if they are available without semantically blocking. This method does not guarantee any additional performance benefits beyond simply recursively calling tryTake, though some implementations will provide a more efficient implementation.

Value parameters

maxN

The max elements to dequeue. Passing None will try to dequeue the whole queue.

Attributes

Returns

an effect that contains the dequeued elements

Inherited from:
QueueSource
Source
QueueSource.scala
def unsafeTryOffer(a: A): Boolean

Attributes

Inherited from:
BoundedQueueSink
Source
BoundedQueueSink.scala