zio.blocks.streams.queues.BlockingMpscQueue
A blocking MPSC (multi-producer, single-consumer) queue.
Backed by MpscRingBuffer for the fast path; uses LockSupport.park and LockSupport.unpark for blocking when the buffer is full or empty.
Multiple threads may call offer concurrently. Only a single thread may call take , drain , isEmpty , or isClosed .
Multi-producer parking: a single producerWaiter volatile slot is used. One producer registers and gets fast-path unpark from consumer. Others use parkNanos(1000) (1µs) to retry — VT-friendly, no starvation.
Null elements are not permitted.
Value parameters
capacity
The logical capacity. Rounded up to the next power of two internally.
Attributes
Source
BlockingMpscQueue.scala
Graph
Reset zoom Hide graph Show graph
Supertypes
trait Matchable
class Any
Members list
Closes the queue, unblocking any waiting thread on either side.
Drains up to limit elements from the queue and passes each to consumer.
Drains up to limit elements from the queue and passes each to consumer.
Value parameters
consumer
callback invoked for each drained element
limit
maximum number of elements to drain
Attributes
Returns
number of elements drained
Source
BlockingMpscQueue.scala
Whether the queue has been closed.
Whether the ring buffer contains no elements.
Offers an element to the queue, blocking until space is available or the queue is closed. Returns true on success, false if the queue was closed.
Offers an element to the queue, blocking until space is available or the queue is closed. Returns true on success, false if the queue was closed.
Attributes
Source
BlockingMpscQueue.scala
Takes an element from the queue, blocking until one is available or the queue is closed. Returns the element, or null if closed and empty.
Takes an element from the queue, blocking until one is available or the queue is closed. Returns the element, or null if closed and empty.
Attributes
Source
BlockingMpscQueue.scala