AsyncQueue Class

    Package: @esfx/async-queue

    An asynchronous queue.

    Declaration
    export declare class AsyncQueue<T> 

    Constructors

    constructor(iterable)

    Initializes a new instance of the AsyncQueue class.

    Declaration
    constructor(iterable?: Iterable<T | PromiseLike<T>>);
    Parameters
    iterable
    Iterable<T | PromiseLike<T>>

    An optional iterable of values or promises.

    Properties

    done

    Gets a value indicating whether the queue has ended and there are no more items available.

    Declaration
    get done(): boolean;
    Property Value
    boolean

    readable

    Gets a value indicating whether items can be read from the queue.

    Declaration
    get readable(): boolean;
    Property Value
    boolean

    size

    Gets the number of entries in the queue. When positive, indicates the number of entries available to get. When negative, indicates the number of requests waiting to be fulfilled.

    Declaration
    get size(): number;
    Property Value
    number

    writable

    Gets a value indicating whether new items can be added to the queue.

    Declaration
    get writable(): boolean;
    Property Value
    boolean

    Methods

    doneReading()

    Blocks attempts to read from the queue until it is empty. Available items in the queue can still be read until the queue is empty.

    Declaration
    doneReading(): void;
    Returns
    void

    doneWriting()

    Blocks attempts to write to the queue. Pending requests in the queue can still be resolved until the queue is empty.

    Declaration
    doneWriting(): void;
    Returns
    void

    end()

    Blocks future attempts to read or write from the queue. Available items in the queue can still be read until the queue is empty. Pending reads from the queue are rejected with a CancelError.

    Declaration
    end(): void;
    Returns
    void

    get(cancelable)

    Removes and returns a Promise for the first value in the queue. If the queue is empty, returns a Promise for the next value to be added to the queue.

    Declaration
    get(cancelable?: Cancelable): Promise<T>;
    Parameters
    cancelable
    Cancelable

    A Cancelable used to cancel the request.

    Returns
    Promise<T>

    put(this)

    Adds a value to the end of the queue. If the queue is empty but has a pending dequeue request, the value will be dequeued and the request fulfilled.

    Declaration
    put(this: AsyncQueue<void>): void;
    Parameters
    this
    AsyncQueue<void>

    Returns
    void

    put(value)

    Adds a value to the end of the queue. If the queue is empty but has a pending dequeue request, the value will be dequeued and the request fulfilled.

    Declaration
    put(value: T | PromiseLike<T>): void;
    Parameters
    value
    T | PromiseLike<T>

    A value or promise to add to the queue.

    Returns
    void

    Generated by DocFX