CompiledModelPool class
A round-robin pool of CompiledModel instances for the LiteRT Next engine.
A single CompiledModel is not safe to drive from overlapping calls, and its scratch input buffer must not be overwritten while an inference is still reading it. Each slot therefore bundles its own model, its own reusable input Float32List, and an AsyncLock that serializes that slot's calls.
withModel hands work to the next slot round-robin, so concurrent calls —
e.g. one per detected hand/person dispatched via Future.wait — land on
distinct slots and overlap, while two calls colliding on the same slot run
back-to-back.
A pool of size 1 is the safe degenerate case: every call serializes through the single slot's lock and shares its one buffer, exactly equivalent to a single CompiledModel guarded by a lock.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialized → bool
-
True once initialize has built at least one slot.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Number of slots (models) in the pool.
no setter
Methods
-
dispose(
) → void - Closes every CompiledModel and clears all slots.
-
initialize(
{required int poolSize, required int inputFloats, required CompiledModel create(), void onFirstModel(CompiledModel firstModel)?}) → void -
Builds
poolSizeslots (clamped to at least 1), disposing any existing ones first. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withModel<
T> (Future< T> task(CompiledModel model, Float32List input)) → Future<T> -
Runs
taskon the next slot (round-robin), serialized against other calls on that same slot.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited