Skip to content

BlockingQueue

Defined in: packages/data/src/queue/blocking-queue.ts:25

A FIFO queue that holds at most capacity items, and whose waitEnqueue suspends until room frees up instead of throwing.

enqueue still throws — this type adds a way to wait, it does not change the way to fail. A capacity of 0 is legal and never grants room: every waitEnqueue blocks until a consumer is there to take the item, which is the rendezvous semantics @ac-kit/async’s Channel is built on.

T extends DefinedValue

The type of elements in the queue.

new BlockingQueue<T>(iterable, options): BlockingQueue<T>

Defined in: packages/data/src/queue/blocking-queue.ts:32

Iterable<T, any, any> | undefined

BlockingQueueOptions<T>

BlockingQueue<T>

readonly capacity: number

Defined in: packages/data/src/queue/blocking-queue.ts:30

The maximum number of elements the collection can hold.

Note: Infinity is not a legal value here — an unbounded type omits this mixin.

IWaitableQueue.capacity

[iterator](): Iterator<T>

Defined in: packages/data/src/queue/blocking-queue.ts:46

Iterator<T>

IWaitableQueue.[iterator]


clear(): void

Defined in: packages/data/src/queue/blocking-queue.ts:50

Removes all elements from the collection.

void

IWaitableQueue.clear


count(): number

Defined in: packages/data/src/queue/blocking-queue.ts:57

The number of elements in the collection.

A method, not a getter: its async counterpart needs a round trip to the backing store, and a member must have the same shape in both.

number

IWaitableQueue.count


dequeue(): T | undefined

Defined in: packages/data/src/queue/blocking-queue.ts:94

Removes and returns the item at the front of the queue.

T | undefined

The item at the front of the queue, or undefined if the queue is empty.

IWaitableQueue.dequeue


enqueue(item): void

Defined in: packages/data/src/queue/blocking-queue.ts:61

Adds an item to the rear of the queue.

T

The item to add to the queue.

void

IWaitableQueue.enqueue


enqueueAll(items): void

Defined in: packages/data/src/queue/blocking-queue.ts:66

Adds every item to the rear of the queue, in array order, so the last one is the last to be dequeued.

readonly T[]

The items to add to the queue.

void

IWaitableQueue.enqueueAll


front(): T | undefined

Defined in: packages/data/src/queue/blocking-queue.ts:104

Returns the item at the front of the queue without removing it.

T | undefined

The item at the front of the queue, or undefined if the queue is empty.

IWaitableQueue.front


waitEnqueue(item, signal?): Promise<void>

Defined in: packages/data/src/queue/blocking-queue.ts:75

Same as enqueue, but waits for capacity if the operation would exceed it.

T

AbortSignal | null

Optional abort signal to cancel the operation.

Promise<void>

IQueue.enqueue

IWaitableQueue.waitEnqueue


waitEnqueueAll(items, signal?): Promise<void>

Defined in: packages/data/src/queue/blocking-queue.ts:80

Same as enqueueAll, but waits for capacity if the operation would exceed it. The whole batch lands at once, never interleaved with another waiter’s.

Iterable<T>

AbortSignal | null

Optional abort signal to cancel the operation.

Promise<void>

IQueue.enqueueAll

IWaitableQueue.waitEnqueueAll