IsolatePool class

Isolate pool creates and starts a given number of isolates (passed to constructor) and schedules execution of single jobs (see PooledJob) or puts and keeps their instacnes of PooledInstance allowing to comunicate with those. Job is a one-time object that allows to schedule a single unit of computation, run it on one of the isolates and return back the result. Jobs do not persist between calls. Pooled instances persist in isolates, can store own state and respond to a number of calls.

Constructors

IsolatePool(int numberOfIsolates)
Prepare the pool of numberOfIsolates isolates to be latter started by IsolatePool.start

Properties

creationCompleters Map<int, Completer<PooledInstanceProxy>>
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
jobCompleters Map<int, Completer>
final
lastJobStartedIndex int
getter/setter pair
numberOfIsolates int
final
numberOfPendingRequests int
no setter
numberOfPooledInstances int
no setter
receivePorts List<ReceivePort>
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
started Future
A pool can be started early on upon app launch and checked latter and awaited to if not started yet
no setter
state IsolatePoolState
no setter

Methods

addInstance(PooledInstance instance, [PooledCallbak? callbak]) Future<PooledInstanceProxy>
Transfer PooledInstance to one of isolates, call it's PooledInstance.init method and make it avaialble for communication via the PooledInstanceProxy returned
destroyInstance(PooledInstanceProxy instance) → void
Remove the instance from internal isolate dictionary and make it available for garbage collection
indexOfPi(PooledInstanceProxy instance) int
Returns the number of isolate the Pooled Instance lives in, -1 if instance is not found
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scheduleJob<T>(PooledJob job) Future<T>
Schedules a job on one of pool's isolates, executes and returns the result. Re-throws expcetion should the action fail in the executing isolate
start() Future
Start the pool
stop() → void
Throws if there're pending jobs or requests
toString() String
A string representation of this object.
inherited

Operators

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