ComputePool class

The worker isolates of Dox().compute and Hash.makeAsync.

One pool for the whole process. The isolate that opens port first owns it: the main isolate in the web server, else the isolate that uses it first (a CLI command, a test, a queue worker). Other server isolates connect to it and send their tasks there.

The workers start on the first task and stay. Tasks beyond the pool size wait in a FIFO queue. The pool never keeps the process alive: only a caller that waits for a result does.

Properties

failSpawns ↔ int
Tests only: the next this many spawns fail.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
port → SendPort
The port other isolates send their tasks to. Opens the pool in this isolate. The workers do not start yet.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size ↔ int
the number of workers. Read when the workers start, so set it before the first task. Dox().initialize sets it from AppConfig.computeWorkers.
getter/setter pair
workerCount → int
workers alive or starting
no setter

Methods

close() → void
Stop the workers. Running and waiting tasks fail with a StateError. A connected isolate only stops sending to the owner. A later run starts a new pool.
connect(SendPort? owner) → void
send the tasks of this isolate to the pool behind owner (a port of another isolate). null runs a pool in this isolate.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run<R>(FutureOr<R> task()) → Future<R>
run task on a worker and give its result. An error of the task is thrown here, with the stack trace of the worker.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Properties

instance → ComputePool
one per isolate
final