Queue
in package
Queue is an ordered sequence of values with support for concurrent consumption.
complete() can be used to signal completeness of the queue, no new items will be queued.
error() can be used to signal errors in the queue, no new items can be queued.
Tags
Table of Contents
Properties
- $state : QueueState<string|int, T>
Methods
- __construct() : mixed
- complete() : void
- Completes the queue.
- error() : void
- Errors the queue with the given reason.
- isComplete() : bool
- isDisposed() : bool
- iterate() : ConcurrentIterator<string|int, T>
- Returns a {@see ConcurrentIterator} to consume the queue.
- pipe() : Pipeline<string|int, T>
- Returns a {@see Pipeline} to consume the queue.
- push() : void
- Pushes a value to the buffer or waits until the value is consumed if the buffer is full or the queue is unbuffered.
- pushAsync() : Future<string|int, null>
- Enqueues a value to the queue, returning a future that is completed once the value is inserted into the buffer or consumed in case of an unbuffered queue.
Properties
$state read-only
private
QueueState<string|int, T>
$state
Has public emit, complete, and fail methods.
Methods
__construct()
public
__construct([int $bufferSize = 0 ]) : mixed
Parameters
- $bufferSize : int = 0
-
Allowed number of items to internally buffer before awaiting backpressure from the consumer of the queue.
complete()
Completes the queue.
public
complete() : void
error()
Errors the queue with the given reason.
public
error(Throwable $reason) : void
Parameters
- $reason : Throwable
isComplete()
public
isComplete() : bool
Return values
bool —True if the queue has been completed or errored.
isDisposed()
public
isDisposed() : bool
Return values
bool —True if the queue has been disposed.
iterate()
Returns a {@see ConcurrentIterator} to consume the queue.
public
iterate() : ConcurrentIterator<string|int, T>
Return values
ConcurrentIterator<string|int, T>pipe()
Returns a {@see Pipeline} to consume the queue.
public
pipe() : Pipeline<string|int, T>
Return values
Pipeline<string|int, T>push()
Pushes a value to the buffer or waits until the value is consumed if the buffer is full or the queue is unbuffered.
public
push(T $value) : void
Use pushAsync() to push a value without waiting for consumption or free buffer space.
Parameters
- $value : T
Tags
pushAsync()
Enqueues a value to the queue, returning a future that is completed once the value is inserted into the buffer or consumed in case of an unbuffered queue.
public
pushAsync(T $value) : Future<string|int, null>
await() the Future returned at a later time, or use push() to await the value being inserted into the buffer or consumed immediately.
Parameters
- $value : T
Return values
Future<string|int, null> —Completes with null when the emitted value has been consumed or errors with DisposedException if the queue has been disposed.