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) → {*}

Source:
Get an item from the queue if it is not empty. Otherwise block until an item is available.
Parameters:
Name Type Attributes Description
options QueueWaitOptions <optional>
Returns:
An item from the head of the queue.
Type
*

(async) getAll(optionsopt) → {Array}

Source:
Get all items from the queue.
Parameters:
Name Type Attributes Description
options QueueWaitOptions <optional>
Returns:
An array of items from the queue.
Type
Array

getAllNoWait()

Source:
Get all items from the queue without waiting.

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)

Source:
Wait for an item to be available.
Parameters:
Name Type Attributes Description
options QueueWaitOptions <optional>