Class AsyncQueue<T>

Asynchronous queue decouples value producers and value consumers.

Type Parameters

  • T = any

    The value stored in the queue.

Constructors

Accessors

Methods

Constructors

Accessors

  • get size(): number
  • Returns the number of values stored in this queue.

    Returns number

Methods

  • Iterates over elements that are available in the queue.

    Returns IterableIterator<T>

  • Appends a new value to the end of the queue.

    Parameters

    • value: T

      The value to append.

    Returns this

  • Returns a promise that is fulfilled with a value when it is available.

    Values are taken in the same order they were appended. Taken values are removed from the queue.

    Returns AbortablePromise<T>

    The promise that is fulfilled with a value that was added to the queue. Aborting the returned promise after the value was taken is a no-op.

  • Returns a promise that is fulfilled with a value and an acknowledgement callback.

    The promise is fulfilled when a value is available. Consequent consumers are blocked until the acknowledgement callback is invoked. Invoking acknowledgement callback multiple times is a no-op.

    Note: Be sure to always call an acknowledgement callback. Otherwise, consequent consumers would never be fulfilled.

    Returns AbortablePromise<ValueAck<T>>

    A tuple that contains a value available in the queue, and a callback that acknowledges that the value was processed and should be removed from the queue. Aborting the returned promise after a consumer received an acknowledgement callback is a no-op.