new ProducerConsumerQueue(maxSizeopt, eqCompareropt, capacityPolicyopt, maxDeferredEnqueuesopt, maxDeferredEnqueuesCapacityPolicyopt)
Creates a new, empty ProducerConsumerQueue.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
maxSize |
Number |
<optional> |
Optional. Defaults to Number.MAX_SAFE_INTEGER. Use this parameter to limit the maximum amount of elements this Queue can hold. When the limit is reached and items are being further enqueued, the ProducerConsumerQueue will defer further calls and only resolve them, once space is available and the item has been enqueued. Likewise, an item is dequeued immediately if the queue is non-empty. Otherwise, the call is deferred and resolved once an item becomes available. Adjusting the capacity of this queue will only affect items in it, but not deferred calls to enqueue(). |
eqComparer |
EqualityComparer.<T> |
<optional> |
Optional. Defaults To EqualityComparer |
capacityPolicy |
ConstrainedQueueCapacityPolicy | ProducerConsumerQueueCapacityPolicy | Number |
<optional> |
A policy for how to deal with new items once this queue reaches its maximum capacity and further items are enqueued. Additionally to @see {ConstrainedQueue}, this queue can also defer further calls |
maxDeferredEnqueues |
Number |
<optional> |
Optional. The maximum amount of deferred enqueue-calls. The behavior can be controlled with @see {maxDeferredEnqueuesCapacityPolicy}. |
maxDeferredEnqueuesCapacityPolicy |
ConstrainedQueueCapacityPolicy | Number |
<optional> |
Optional. How to deal with enqueue calls when the queue with deferred calls is full. |
- Source:
Members
capacityPolicy :ConstrainedQueueCapacityPolicy|ProducerConsumerQueueCapacityPolicy|Number
Because we override the setter, we need to override the getter.
Type:
- Source:
capacityPolicy :void
Type:
- void
- Source:
maxDeferredEnqueues :Number
Returns the maximum amount of allowed deferred enqueue calls.
Type:
- Number
- Source:
maxDeferredEnqueues :void
Sets the maximum amount of deferred enqueue calls. If the new amount
is smaller than the currently waiting calls, then calls will be dequeued
in a FIFO manner and rejected.
Type:
- void
- Source:
- See:
-
- {_truncateDeferredEnqueues}
maxDeferredEnqueuesCapacityPolicy :ConstrainedQueueCapacityPolicy|Number
Returns the policy for dealing with enqueue calls once the waiting queue
is full.
Type:
- ConstrainedQueueCapacityPolicy | Number
- Source:
maxDeferredEnqueuesCapacityPolicy :void
Set the policy for dealing with enqueue calls once the waiting queue
is full.
Type:
- void
- Source:
numDeferredDequeues :Number
Returns the currently deferred dequeue calls (waiting consumers).
Type:
- Number
- Source:
numDeferredEnqueues :Number
Returns the amount of deferred enqueue calls (waiting producers).
Type:
- Number
- Source:
Methods
dequeue() → {Promise.<T>}
- Source:
Returns:
The promise is resolved once an item is available.
- Type
- Promise.<T>
enqueue(item) → {Promise.<this>}
Parameters:
Name | Type | Description |
---|---|---|
item |
T | The item to be enqueued. |
- Source:
Returns:
The promise is resolved once the item got enqueued.
- Type
- Promise.<this>