IsolatePool class
Persistent isolate pool with work-stealing scheduler and priority queue.
Replaces single-shot compute() calls with a pool of long-running isolates
that eliminate per-frame spawn overhead. Inspired by CameraX's
ImageAnalysis executor pool and Dynamsoft's background processing architecture.
Features:
- Persistent isolate lifecycle (spawn once, reuse across frames)
- Ring-buffer frame queue with configurable depth
- Priority-based scheduling (tap-to-focus frames processed first)
- Frame budget monitoring with auto-quality adjustment
- Graceful shutdown with drain timeout
Constructors
- IsolatePool({int poolSize = 2, int frameQueueDepth = 3})
Properties
- avgProcessingTimeMs → double
-
Rolling average processing time per frame (ms).
no setter
- busyWorkers → int
-
Number of workers currently busy.
no setter
- completedTasks → int
-
Number of tasks completed since initialization.
no setter
- droppedFrames → int
-
Number of frames dropped due to queue overflow.
no setter
- frameQueueDepth → int
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialized → bool
-
Whether the pool is initialized and accepting work.
no setter
- isOverloaded → bool
-
Whether the pool is currently overloaded (all workers busy + queue full).
no setter
- pendingTasks → int
-
Number of tasks currently queued.
no setter
- poolSize → int
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
initialize(
) → Future< void> - Initializes the isolate pool by spawning poolSize persistent workers.
-
isExceedingBudget(
{double targetMs = 40.0}) → bool - Whether frame processing is currently exceeding the target budget.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resetStats(
) → void - Resets statistics counters.
-
shutdown(
{Duration timeout = const Duration(seconds: 2)}) → Future< void> - Gracefully shuts down the pool, completing pending tasks.
-
submit<
T, R> (T taskData, R processor(T), {int priority = 0}) → Future< R> - Submits a frame processing task to the pool.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited