Queue

Queue

A classic producer/consumer construct for regulating work.

Constructor

new Queue(maxsizeopt)

Source:
See:
Parameters:
Name Type Attributes Default Description
maxsize Number <optional>
0 The number of items allowed to be stored before blocking.

Classes

Queue

Members

full :boolean

Source:
true if a call to put would block.
Type:
  • boolean

maxsize :Number

Source:
The maximum number of items that can be enqueued.
Type:
  • Number

size :Number

Source:
The number of items waiting to be dequeued.
Type:
  • Number

Methods

(protected) _get()

Source:

(protected) _put()

Source:

(async) get(optionsopt) → {Future.<*>}

Source:
Get an item from the queue if it is not empty. The returned Future MUST be cancelled if the caller is no longer wanting the queue item.
Parameters:
Name Type Attributes Description
options QueueWaitOptions <optional>
Returns:
An item from the head of the queue.
Type
Future.<*>

(async) getAll(optionsopt) → {Future.<Array.<*>>}

Source:
Get all items from the queue. If the queue cannot satisfy the size requirements then it will block. The returned Future MUST be cancelled if the caller is no longer wanting the queue items.
Parameters:
Name Type Attributes Description
options QueueWaitOptions <optional>
Returns:
A Future that resolves with an Array of items from the queue.
Type
Future.<Array.<*>>

getAllNoWait() → {Array.<*>}

Source:
Get all items from the queue without waiting.
Returns:
An Array of items from the queue.
Type
Array.<*>

getNoWait() → {*}

Source:
Get an item from the queue if it is not empty.
Throws:
Returns:
An item from the head of the queue.
Type
*

(async) join()

Source:
Will block until all items are dequeued and for every item that was dequeued a call was made to taskdone.

(async) put(item)

Source:
Place a new item in the queue if it is not full. Otherwise block until space is available.
Parameters:
Name Type Description
item * Any object to pass to the caller of dequeue.

putNoWait(item)

Source:
Place a new item in the queue if it is not full.
Parameters:
Name Type Description
item * Any object to pass to the caller of dequeue.
Throws:

taskDone(countopt)

Source:
Decrement the number of pending tasks. Called by consumers after completing their use of a dequeued item to indicate that processing has finished. When all dequeued items have been accounted for with an accompanying call to this function join will unblock.
Parameters:
Name Type Attributes Default Description
count Number <optional>
1 The number of tasks to mark as done.

(async) wait(optionsopt) → {Future}

Source:
Wait for an item to be available. Users should cancel the returned Future if they are no longer wanting data. Such as when used in Promise.race.
Parameters:
Name Type Attributes Description
options QueueWaitOptions <optional>
Returns:
Resolves when data is available to get.
Type
Future