BoundedWorkQueue<T> class
A bounded FIFO channel of T with blocking push/pull and backpressure.
Constructors
-
BoundedWorkQueue({required int maxSize})
-
Creates a queue holding at most
maxSize buffered items (maxSize ≥ 1).
Audited: 2026-06-12 11:26 EDT
Properties
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
isClosed
→ bool
-
Whether close has been called.
no setter
-
isFull
→ bool
-
Whether the buffer is at capacity (the next push will block).
Audited: 2026-06-12 11:26 EDT
no setter
-
length
→ int
-
Buffered (not-yet-pulled) item count.
Audited: 2026-06-12 11:26 EDT
no setter
-
maxSize
→ int
-
Maximum number of items buffered before push starts applying backpressure.
final
-
pendingConsumers
→ int
-
Consumers currently blocked waiting for an item.
Audited: 2026-06-12 11:26 EDT
no setter
-
pendingProducers
→ int
-
Producers currently blocked waiting for a free slot.
Audited: 2026-06-12 11:26 EDT
no setter
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close()
→ void
-
Closes the queue: blocks further pushes, fails every blocked producer and
consumer with StateError, and lets consumers drain any already-buffered
items (a pull on the empty closed queue then errors). Buffered items are
NOT discarded — drain them before closing if they matter.
Audited: 2026-06-12 11:26 EDT
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
pull()
→ Future<T>
-
Dequeues the next item, returning a future that completes once one is
available. When the buffer is empty the future stays pending until a push
arrives. If the queue is closed AND empty, completes with StateError.
Audited: 2026-06-12 11:26 EDT
-
push(T item)
→ Future<void>
-
Enqueues
item, returning a future that completes once it is buffered (or
handed directly to a waiting consumer). When the buffer is full the future
stays pending until a pull frees a slot — the backpressure signal. The
future completes with StateError if the queue is (or becomes) closed.
Audited: 2026-06-12 11:26 EDT
-
toString()
→ String
-
A string representation of this object.
override
-
tryPull()
→ T?
-
Non-blocking pull: returns the next buffered item, or null if the buffer
is empty. NOTE: with a nullable
T a buffered null is indistinguishable
from "empty" here — use pull when T is nullable.
Audited: 2026-06-12 11:26 EDT
-
tryPush(T item)
→ bool
-
Non-blocking push: enqueues
item and returns true if there was room (or
a waiting consumer), or false without blocking if the buffer is full.
Throws StateError if the queue is closed.
Audited: 2026-06-12 11:26 EDT