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
Properties
done
Gets a value indicating whether the queue has ended and there are no more items available.
Declaration
get done(): boolean;
Property Value
readable
Gets a value indicating whether items can be read from the queue.
Declaration
get readable(): boolean;
Property Value
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
writable
Gets a value indicating whether new items can be added to the queue.
Declaration
get writable(): boolean;
Property Value
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
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
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
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
Returns
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
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
Returns