ZQueue

abstract class ZQueue[-RA, -RB, +EA, +EB, -A, +B] extends Serializable

A ZQueue[RA, RB, EA, EB, A, B] is a lightweight, asynchronous queue into which values of type A can be enqueued and of which elements of type B can be dequeued. The queue's enqueueing operations may utilize an environment of type RA and may fail with errors of type EA. The dequeueing operations may utilize an environment of type RB and may fail with errors of type EB.

Companion:
object
class Object
trait Matchable
class Any
ZQueue[RA, RB, EA, EB, A, B]

Value members

Abstract methods

Waits until the queue is shutdown. The IO returned by this method will not resume until the queue has been shutdown. If the queue is already shutdown, the IO will resume right away.

Waits until the queue is shutdown. The IO returned by this method will not resume until the queue has been shutdown. If the queue is already shutdown, the IO will resume right away.

How many elements can hold in the queue

How many elements can hold in the queue

true if shutdown has been called.

true if shutdown has been called.

def offer(a: A): ZIO[RA, EA, Boolean]

Places one value in the queue.

Places one value in the queue.

def offerAll(as: Iterable[A]): ZIO[RA, EA, Boolean]

For Bounded Queue: uses the BackPressure Strategy, places the values in the queue and always returns true. If the queue has reached capacity, then the fiber performing the offerAll will be suspended until there is room in the queue.

For Bounded Queue: uses the BackPressure Strategy, places the values in the queue and always returns true. If the queue has reached capacity, then the fiber performing the offerAll will be suspended until there is room in the queue.

For Unbounded Queue: Places all values in the queue and returns true.

For Sliding Queue: uses Sliding Strategy If there is room in the queue, it places the values otherwise it removes the old elements and enqueues the new ones. Always returns true.

For Dropping Queue: uses Dropping Strategy, It places the values in the queue but if there is no room it will not enqueue them and return false.

Interrupts any fibers that are suspended on offer or take. Future calls to offer* and take* will be interrupted immediately.

Interrupts any fibers that are suspended on offer or take. Future calls to offer* and take* will be interrupted immediately.

def size: UIO[Int]

Retrieves the size of the queue, which is equal to the number of elements in the queue. This may be negative if fibers are suspended waiting for elements to be added to the queue.

Retrieves the size of the queue, which is equal to the number of elements in the queue. This may be negative if fibers are suspended waiting for elements to be added to the queue.

def take: ZIO[RB, EB, B]

Removes the oldest value in the queue. If the queue is empty, this will return a computation that resumes when an item has been added to the queue.

Removes the oldest value in the queue. If the queue is empty, this will return a computation that resumes when an item has been added to the queue.

def takeAll: ZIO[RB, EB, List[B]]

Removes all the values in the queue and returns the list of the values. If the queue is empty returns empty list.

Removes all the values in the queue and returns the list of the values. If the queue is empty returns empty list.

def takeUpTo(max: Int): ZIO[RB, EB, List[B]]

Takes up to max number of values in the queue.

Takes up to max number of values in the queue.

Concrete methods

final def contramap[C](f: C => A): ZQueue[RA, RB, EA, EB, C, B]

Transforms elements enqueued into this queue with a pure function.

Transforms elements enqueued into this queue with a pure function.

final def contramapM[RA2 <: RA, EA2 >: EA, C](f: C => ZIO[RA2, EA2, A]): ZQueue[RA2, RB, EA2, EB, C, B]

Transforms elements enqueued into this queue with an effectful function.

Transforms elements enqueued into this queue with an effectful function.

final def dimap[C, D](f: C => A, g: B => D): ZQueue[RA, RB, EA, EB, C, D]

Transforms elements enqueued into and dequeued from this queue with the specified pure functions.

Transforms elements enqueued into and dequeued from this queue with the specified pure functions.

final def dimapM[RC <: RA, RD <: RB, EC >: EA, ED >: EB, C, D](f: C => ZIO[RC, EC, A], g: B => ZIO[RD, ED, D]): ZQueue[RC, RD, EC, ED, C, D]

Transforms elements enqueued into and dequeued from this queue with the specified effectual functions.

Transforms elements enqueued into and dequeued from this queue with the specified effectual functions.

final def filterInput[A1 <: A](f: A1 => Boolean): ZQueue[RA, RB, EA, EB, A1, B]

Applies a filter to elements enqueued into this queue. Elements that do not pass the filter will be immediately dropped.

Applies a filter to elements enqueued into this queue. Elements that do not pass the filter will be immediately dropped.

final def filterInputM[R2 <: RA, E2 >: EA, A1 <: A](f: A1 => ZIO[R2, E2, Boolean]): ZQueue[R2, RB, E2, EB, A1, B]

Like filterInput, but uses an effectful function to filter the elements.

Like filterInput, but uses an effectful function to filter the elements.

final def filterOutput(f: B => Boolean): ZQueue[RA, RB, EA, EB, A, B]

Filters elements dequeued from the queue using the specified predicate.

Filters elements dequeued from the queue using the specified predicate.

def filterOutputM[RB1 <: RB, EB1 >: EB](f: B => ZIO[RB1, EB1, Boolean]): ZQueue[RA, RB1, EA, EB1, A, B]

Filters elements dequeued from the queue using the specified effectual predicate.

Filters elements dequeued from the queue using the specified effectual predicate.

final def map[C](f: B => C): ZQueue[RA, RB, EA, EB, A, C]

Transforms elements dequeued from this queue with a function.

Transforms elements dequeued from this queue with a function.

final def mapM[R2 <: RB, E2 >: EB, C](f: B => ZIO[R2, E2, C]): ZQueue[RA, R2, EA, E2, A, C]

Transforms elements dequeued from this queue with an effectful function.

Transforms elements dequeued from this queue with an effectful function.

final def poll: ZIO[RB, EB, Option[B]]

Take the head option of values in the queue.

Take the head option of values in the queue.

final def takeBetween(min: Int, max: Int): ZIO[RB, EB, List[B]]

Takes a number of elements from the queue between the specified minimum and maximum. If there are fewer than the minimum number of elements available, suspends until at least the minimum number of elements have been collected.

Takes a number of elements from the queue between the specified minimum and maximum. If there are fewer than the minimum number of elements available, suspends until at least the minimum number of elements have been collected.

final def takeN(n: Int): ZIO[RB, EB, List[B]]

Takes the specified number of elements from the queue. If there are fewer than the specified number of elements available, it suspends until they become available.

Takes the specified number of elements from the queue. If there are fewer than the specified number of elements available, it suspends until they become available.

Deprecated methods

@deprecated("use ZStream", "2.0.0")
final def &&[RA1 <: RA, RB1 <: RB, EA1 >: EA, EB1 >: EB, A1 <: A, C, D](that: ZQueue[RA1, RB1, EA1, EB1, A1, C]): ZQueue[RA1, RB1, EA1, EB1, A1, (B, C)]

Alias for both.

Alias for both.

Deprecated
@deprecated("use ZStream", "2.0.0")
final def both[RA1 <: RA, RB1 <: RB, EA1 >: EA, EB1 >: EB, A1 <: A, C, D](that: ZQueue[RA1, RB1, EA1, EB1, A1, C]): ZQueue[RA1, RB1, EA1, EB1, A1, (B, C)]

Like bothWith, but tuples the elements instead of applying a function.

Like bothWith, but tuples the elements instead of applying a function.

Deprecated
@deprecated("use ZStream", "2.0.0")
final def bothWith[RA1 <: RA, RB1 <: RB, EA1 >: EA, EB1 >: EB, A1 <: A, C, D](that: ZQueue[RA1, RB1, EA1, EB1, A1, C])(f: (B, C) => D): ZQueue[RA1, RB1, EA1, EB1, A1, D]

Like bothWithM, but uses a pure function.

Like bothWithM, but uses a pure function.

Deprecated
@deprecated("use ZStream", "2.0.0")
final def bothWithM[RA1 <: RA, RB1 <: RB, R3 <: RB1, EA1 >: EA, EB1 >: EB, E3 >: EB1, A1 <: A, C, D](that: ZQueue[RA1, RB1, EA1, EB1, A1, C])(f: (B, C) => ZIO[R3, E3, D]): ZQueue[RA1, R3, EA1, E3, A1, D]

Creates a new queue from this queue and another. Offering to the composite queue will broadcast the elements to both queues; taking from the composite queue will dequeue elements from both queues and apply the function point-wise.

Creates a new queue from this queue and another. Offering to the composite queue will broadcast the elements to both queues; taking from the composite queue will dequeue elements from both queues and apply the function point-wise.

Note that using queues with different strategies may result in surprising behavior. For example, a dropping queue and a bounded queue composed together may apply f to different elements.

Deprecated