TissueQueue<E> class abstract interface

A reactive, high‑performance, and synchronised implementation of a Double‑Ended Queue (Deque) that adheres to the standard Dart Queue contract.

TissueQueue serves as the primary bridge between traditional imperative data structures and the Conactive Model. It provides a robust, thread‑safe buffer where every modification—whether inserting at the head, removing from the tail, or clearing the collection—is treated as a formal reactive event. This allows the queue to be observed, validated, and synchronised across the entire cell network.

When to use

Use a TissueQueue whenever you need a FIFO (or double‑ended) buffer that:

  • Must be observable (UI updates automatically on changes).
  • Must enforce invariants (e.g., max size, element type).
  • Must be shared between components with different permissions (via deputies).
  • Must participate in the reactive graph as a first‑class cell.
  • Requires high‑performance add/remove at both ends (O(1)).

Most of the time, you create a TissueQueue using the TissueQueue factory, optionally providing a capacity for bounded queues and a testRule for validation:

final queue = TissueQueue<int>(capacity: 10);
final validated = TissueQueue<String>(
  testRule: TestTissue<String>((v) => v.isNotEmpty),
);

How it works

  • Internally, it uses a TissueQueueNucleus to govern behaviour and a Container.queue for physical storage (a Dart Queue<E>).
  • Every mutation (e.g., add, addFirst, removeLast, clear) goes through a validation pipeline (testRule) and emits a TissuePulse.
  • The queue is thread‑safe via its internal Lock.
  • It can be deputised to create restricted views (read‑only, scoped authority, bounded sub‑queues, etc.) that share the same storage.
  • It supports both unbounded and bounded capacities (backpressure).
  • It automatically links child Cells when they are added, enabling "bubbling" of internal changes.

Example: Basic usage

final queue = TissueQueue<String>();
queue.add('A');
queue.add('B');
print(queue.removeFirst()); // 'A'

// Listen for changes
queue.listen((event) {
  if (event.type == Tissue.elementAdded) {
    print('Added: ${event.payload}');
  }
});
queue.add('C'); // prints "Added: C"

Example: Bounded queue (backpressure)

final bounded = TissueQueue<int>(capacity: 3);
bounded.addAll([1, 2, 3]);
bounded.add(4); // drops the oldest (1) – queue now contains [2, 3, 4]

Example: Validation

final validQueue = TissueQueue<int>(
  testRule: TestTissue<int>((v) => v >= 0),
);
validQueue.add(5); // allowed
validQueue.add(-1); // rejected – no event emitted

Example: Read‑only deputy for UI

final source = TissueQueue<String>();
final uiView = source.deputy(testRule: TestTissue.readOnly);
// uiView can be safely passed to a widget tree
// Changes to source are reflected in uiView automatically

Type Parameters:

  • E: The type of elements held within the queue.

See also:

AI Agent Guide

Layer: Tissue — outbound work. Not a Cell factory, not a Flow operator. When to use: "alert the supervisor / RTU / issuer" — audit enqueue (addLast(job)) with an optional capacity for backpressure; the Dart list + _driveAlert is the retry-once pump. When NOT to use:

Live signature: TissueQueue<E>({bind, context, testRule, receptor, synapses, ...}) / TissueQueue.of(iterable, {...}) / TissueQueue.unmodifiable(bind, {...}) — pinned at cell_tissue: 1.2.0 Do NOT confuse with: TissueList (indexable history; use the queue for FIFO work). Guide: HowTo-Mitose-Tissue.md §2.4 "TissueQueue — outbound work" (#tissue-queue) Example: example/cell_tissue_example.dart Cross-layer: enqueues happen in Cell.observe; the pump is harness code. Minimal compilable example

final q = TissueQueue<int>(capacity: 3);
q.addLast(1);
q.addLast(2);
print(q.length); // 2
Implemented types
Available extensions

Constructors

TissueQueue({int? capacity, Cell? bind, Context context, TissueReceptor<E, TissueQueue<E>> receptor, TestTissue<E, TissueQueue<E>> testRule, Synapses<Pulse, Cell> synapses})
The primary architectural factory for instantiating a TissueQueue, creating a reactive, double‑ended buffer governed by the Conactive Model.
factory
TissueQueue.fromJson(Map<String, dynamic> json, {TissueCellResolver? cellResolver, TissueGovernanceResolver? governanceResolver, bool lenient = false, TestTissue<dynamic, Tissue> lenientFallbackTestRule = TestTissue.readOnly, void onSkipped(List<String> skipped)?, Object? testRule, Context? context, Object? bind, Object? container, Object? capacity, Object? user, List<E>? elements})
Reconstructs a TissueQueue from the canonical JSON produced by encodeTissue / TissueQueueJson.toJson.
factory
TissueQueue.fromNucleus(TissueQueueNucleus<E> nucleus, {Iterable<E>? elements})
Primary architectural factory for materialising a TissueQueue from an existing TissueQueueNucleus (the "Reactive DNA").
factory
TissueQueue.of(Iterable<E> elements, {int? capacity, Cell? bind, Context context, TissueReceptor<E, TissueQueue<E>> receptor, TestTissue<E, TissueQueue<E>> testRule, Synapses<Pulse, Cell> synapses})
Factory constructor to create a new, pre‑populated TissueQueue from an Iterable of elements.
factory
TissueQueue.unmodifiable(TissueQueue<E> bind, {Context? context, bool unmodifiableElement})
A high‑fidelity architectural factory for creating a Deeply Immodifiable Reactive View (Deputy) of an existing TissueQueue.
factory

Properties

async → ModifiableQueueAsync<E>
Creates an async variant for modifiable operations
no setteroverride
context → Context
The Context defining the authority tier, priority, and security domain of this collection.
no setterinherited
first → E
The first element.
no setterinherited
firstOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The first element of this iterator, or null if the iterable is empty.
no setter
hashCode → int
The hash code for this object.
no setterinherited
id → String
A stable, serialisable identifier for this cell handle.
no setterinherited
indexed → Iterable<(int, T)>

Available on Iterable<T>, provided by the IterableExtensions extension

Pairs of elements of the indices and elements of this iterable.
no setter
isEmpty → bool
Whether this collection has no elements.
no setterinherited
isGoverned → bool
Indicates whether this tissue is governed.
no setterinherited
isInvalidated → bool
Indicates whether this tissue has been invalidated by its EphemeralPolicy (e.g., TTL expired).
no setterinherited
isNotEmpty → bool
Whether this collection has at least one element.
no setterinherited
isTerminal → bool
Indicates whether this tissue is a terminal node – i.e., it has no downstream observers and does not broadcast pulses.
no setterinherited
iterator → Iterator<E>
A new Iterator that allows iterating the elements of this Iterable.
no setterinherited
last → E
The last element.
no setterinherited
lastOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The last element of this iterable, or null if the iterable is empty.
no setter
length → int
The number of elements in this Iterable.
no setterinherited
modifiable → Iterable<Function>
The exhaustive whitelist of functions that can be invoked via apply.
no setterinherited
nonNulls → Iterable<T>

Available on Iterable<T?>, provided by the NullableIterableExtensions extension

The non-null elements of this iterable.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
single → E
Checks that this iterable has only one element, and returns that element.
no setterinherited
singleOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The single element of this iterator, or null.
no setter
skippedReport → Map<String, dynamic>?

Available on Tissue<E>, provided by the TissueSkippedReport extension

The {'wire': [...], 'decode': [...]} skip report, or null when no skip occurred.
no setter
toJSIterable → JSIterable<T>

Available on Iterable<T>, provided by the IterableToJSIterable extension

A JSIterable wrapper that proxies to the Dart iterable API.
no setter
unmodifiable → TissueQueue<E>
Returns a read‑only, reactive projection (Deputy) of this TissueQueue.
no setteroverride
validate → TestTissue<dynamic, Tissue>
The TestTissue validation logic currently governing this collection.
no setterinherited
wait → Future<List<T>>

Available on Iterable<Future<T>>, provided by the FutureIterable extension

Waits for futures concurrently.
no setter

Methods

add(E value) → void
Adds value at the end of the queue.
override
addAll(Iterable<E> iterable) → void
Adds all values iterable at the end of the queue.
override
addFirst(E value) → void
Adds value at the beginning of the queue.
override
addLast(E value) → void
Adds value at the end of the queue.
override
any(bool test(E element)) → bool
Checks whether any element of this iterable satisfies test.
inherited
apply<R>(ApplyCommand command, {ApplyTransactionScope? tx}) → FutureOr<ApplyOutcome<R>>
Executes a governed mutation on this tissue through the command gateway.
inherited
asNameMap() → Map<String, T>

Available on Iterable<T>, provided by the EnumByName extension

Creates a map from the names of enum values to the values.
attach(dynamic context) → Iterable<Pulse>

Available on Iterable<Pulse>, provided by the PulseIterableExtension extension

Returns a new collection of pulses, each with the provided context metadata attached.
batch() → Pulse

Available on Iterable<Pulse>, provided by the PulseIterableExtension extension

Aggregates multiple signals into a single, flat CollectivePulse.
byName(String name) → T

Available on Iterable<T>, provided by the EnumByName extension

Finds the enum value in this list with name name.
cast<R>() → Queue<R>
Provides a view of this queue as a queue of R instances, if necessary.
override
clear() → void
Clears the queue.
override
command(Function function) → ApplyCommandRunner

Available on Cell, provided by the ApplyCommandDSL extension

Begins assembling a command that invokes function on this cell.
contains(Object? element) → bool
Whether the collection contains an element equal to element.
inherited
deputy({covariant DeputyContext context = DeputyContext.system, covariant TestTissue<dynamic, Tissue> testRule = TestTissue.allowAll, EphemeralPolicy<Cell>? ephemeralPolicy, Synapses<Pulse, Cell> synapses = Synapses.enabled}) → FutureOr<TissueQueue<E>>
Creates a delegated view (deputy) of this queue with specialised behavioural, security, and validation logic.
override
elementAt(int index) → E
Returns the indexth element.
inherited
elementAtOrNull(int index) → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The element at position index of this iterable, or null.
every(bool test(E element)) → bool
Checks whether every element of this iterable satisfies test.
inherited
expand<T>(Iterable<T> toElements(E element)) → Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
filter<S>({required bool test(S value)}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Materializes a Predicate Integrity Gate—a specialized orchestration instruction designed to conditionally permit pulse evolution.
firstWhere(covariant bool test(E element), {covariant E orElse()?}) → E
The first element that satisfies the given predicate test.
inherited
flatten() → Iterable<Pulse>

Available on Iterable<Pulse>, provided by the PulseIterableExtension extension

Recursively flattens any nested CollectivePulse structures into a sequence of simple pulses.
fold<T>(T initialValue, T combine(T previousValue, E element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(covariant Iterable<E> other) → Iterable<E>
Creates the lazy concatenation of this iterable and other.
inherited
forEach(void action(E value)) → void
Invokes action on each element of this iterable in iteration order.
inherited
fromFuture<S>({required Future<S> future, Duration? timeout, FutureErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Synthesizes a Temporal Resource Bridge from a Future.
fromIterable<T>({required Iterable<T> iterable}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Synthesizes an Iterative Pulse Bridge from a dynamic iterable.
fromStream<S>({required Stream<S> stream, StreamErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Synthesizes a Continuous Pulse Bridge from a Stream.
join([String separator = ""]) → String
Converts each element to a String and concatenates the strings.
inherited
lastWhere(covariant bool test(E element), {covariant E orElse()?}) → E
The last element that satisfies the given predicate test.
inherited
map<T>(T toElement(E e)) → Iterable<T>
The current elements of this iterable modified by toElement.
inherited
map<S, T>({required T project(S value), MapErrorHandler? onError}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Materializes a Projective Evolution Gate—a fundamental instruction designed to transform stimulus payloads as they traverse the topography.
mapEach<T>(T mapper(dynamic payload)) → Iterable<Pulse<T>>

Available on Iterable<Pulse>, provided by the PulseIterableExtension extension

Transforms the payload of every pulse in the collection while preserving their individual causal traces.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
of<T>({required Iterable<T> values}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Synthesizes a Fixed Sequence Bridge from a provided collection.
range({required int start, required int count, int step = 1}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Synthesizes a Counted Pulse Generator—a specialized bridge designed to evolve a sequence of arithmetic integers.
reduce(covariant E combine(E value, E element)) → E
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
remove(Object? value) → bool
Removes the first occurrence of value from the queue.
override
removeFirst() → E
Removes the first element from the queue.
override
removeLast() → E
Removes the last element from the queue.
override
removeWhere(bool test(E element)) → void
Removes all elements that satisfy the test condition.
override
repeat<T>({required T value, int count = 1}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Synthesizes a Recursive Stimulus Bridge—a specialized generator designed to evolve the same payload multiple times.
retainWhere(bool test(E element)) → void
Retains all elements that satisfy the test condition.
override
singleWhere(bool test(E element), {E orElse()?}) → E
The single element that satisfies test.
inherited
skip(int count) → Iterable<E>
Creates an Iterable that provides all but the first count elements.
inherited
skipWhile(bool test(E element)) → Iterable<E>
Creates an Iterable that skips leading elements while test is satisfied.
inherited
take(int count) → Iterable<E>
Creates a lazy iterable of the count first elements of this iterable.
inherited
takeWhile(bool test(E element)) → Iterable<E>
Creates a lazy iterable of the leading elements satisfying test.
inherited
tap<S>({required void onValue(S value), TapErrorHandler? onError}) → FlowHandle

Available on Cell, provided by the CellFlowOperators extension

Materializes a Passive Observation Gate—a specialized orchestration instruction designed to perform side-effects without altering pulse evolution.
toJson({bool lenient = false, TestTissue<dynamic, Tissue> lenientFallbackTestRule = TestTissue.readOnly}) → Map<String, dynamic>

Available on TissueQueue<E>, provided by the TissueQueueJson extension

Encodes this queue to its canonical JSON wire form.
toList({bool growable = true}) → List<E>
Creates a List containing the elements of this Iterable.
inherited
toSet() → Set<E>
Creates a Set containing the same elements as this iterable.
inherited
toString() → String
A string representation of this object.
inherited
where(bool test(E element)) → Iterable<E>
Creates a new lazy Iterable with all elements that satisfy the predicate test.
inherited
whereType<T>() → Iterable<R>
Creates a new lazy Iterable with all elements that have type T.
inherited
withStep(String step) → Iterable<Pulse>

Available on Iterable<Pulse>, provided by the PulseIterableExtension extension

Appends a diagnostic stage to the causal trace of every pulse in this collection.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

create<E, C extends TissueQueue<E>>({Iterable<E>? elements, Cell? bind, Context? context, TissueReceptor<E, C>? receptor, TestTissue<E, C>? testRule, Synapses<Pulse, Cell>? synapses, Container? container, Record? user, dynamic forceLock = false, TissueQueueNucleusBase<E, C>? principal}) → TissueQueueBase<E, C>
A high‑level, comprehensive static factory for orchestrating the assembly and instantiation of a TissueQueueBase, serving as the primary "Assembly Line" for reactive, double‑ended buffers.
override