GeezerVison is showing adk.dev — AsyncQueue | ADK for TypeScript: API Reference - v2.5.0
A generic, single-consumer async queue that implements AsyncIterable,
bridging a push producer to a pull consumer (for await (const x of q)).
Producers call push as values are produced and close (or
fail) when finished. A single consumer drains the queue.
Semantics:
- Buffered items are always delivered before an end/error signal.
- close ends iteration cleanly (
done: true); idempotent.
- fail surfaces the error to the consumer after any buffered items
have been drained; it is sticky (first failure wins) and also closes the
queue, so a later
close() can't discard the error.
- push after close/fail is ignored (the producer has already
signalled completion).
- pushAndWait resolves once the consumer has finished with the item:
when it asks for the next one, or when the queue closes or fails.
Constructors
constructor
-
new AsyncQueue<T>(): AsyncQueue
<T>
Accessors
isClosed
-
get isClosed(): boolean
Whether the queue has been closed or failed.
Returns boolean
size
-
get size(): number
Number of items buffered and not yet consumed.
Returns number
Methods
[asyncIterator]
-
"[asyncIterator]"(): AsyncIterator<T>
close
-
Signals that no more items will be produced. Any awaiting consumer receives
{done: true}. Idempotent.
Returns void
error
-
error(err: unknown): void
Returns void
Deprecated
Alias for fail; kept for existing callers.
fail
-
fail(error: unknown): void
Signals that production failed. Buffered items are still delivered first;
once the buffer drains, the consumer's next next() rejects with error.
Sticky (first failure wins) and closes the queue.
Returns void
push
-
Enqueues a value. If a consumer is currently awaiting, it is resolved
immediately; otherwise the value is buffered. No-op once closed/failed.
Returns void
pushAndWait
-
pushAndWait(value: T): Promise<void>
Enqueues a value like push, and resolves once the consumer has
finished with it: when it asks for the next item, or when the queue closes
or fails. Resolves at once if the queue is already closed.
Returns Promise<void>
Constructors
Accessors
Methods