IsolateManager<R, P> class

Constructors

IsolateManager.create(IsolateFunction<R, P> isolateFunction, {String? workerName, int concurrent = 1, IsolateConverter<R>? converter, IsolateConverter<R>? workerConverter, QueueStrategy<R, P>? queueStrategy, bool enableWasmConverter = true, bool isDebug = false})
Creates a new IsolateManager for isolate-based computations.
IsolateManager.createCustom(IsolateCustomFunction isolateFunction, {String? workerName, int concurrent = 1, IsolateConverter<R>? converter, IsolateConverter<R>? workerConverter, QueueStrategy<R, P>? queueStrategy, bool enableWasmConverter = true, bool isDebug = false})
Creates a new IsolateManager instance with a custom isolate function.

Properties

concurrent int
Number of concurrent isolates.
final
converter IsolateConverter<R>?
Convert the result received from the isolate before getting real result. This function useful when the result received from the isolate is different from the return type.
final
enableWasmConverter bool
Flag to enable WebAssembly type conversion for numerical values.
final
ensureStarted Future<void>
If you want to call the start method manually without await, you can await later by using ensureStarted to ensure that all the isolates are started.
no setter
hashCode int
The hash code for this object.
no setterinherited
isCustomIsolate bool
Is using your own isolate function.
final
isDebug bool
Allow print debug log.
final
isolateFunction Object
Isolate function.
final
isStarted bool
To check if the start method is completed or not.
no setter
queuesLength int
Get current number of queues.
no setter
queueStrategy QueueStrategy<R, P>
Strategy to control a new (incoming) computation.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<R>
Get value as stream.
no setter
workerConverter IsolateConverter<R>?
Convert the result received from the isolate before getting real result. This function useful when the result received from the isolate is different from the return type.
final
workerName String
Name of the Worker without the extension.
no setter

Methods

call(P params, {IsolateCallback<R>? callback, bool priority = false}) Future<R>
Compute isolate manager with R is return type.
compute(P params, {IsolateCallback<R>? callback, bool priority = false}) Future<R>
Compute isolate manager with R is return type.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause() Future<void>
Pauses the isolate manager, stopping all current operations without terminating the instance.
printDebug(Object? object()) → void
Print logs if isDebug is true
restart() Future<void>
Restarts the isolate manager by stopping and restarting all isolates.
sendMessage(P params, {IsolateCallback<R>? callback, bool priority = false}) Future<R>
Similar to the compute, for who's using IsolateContactor.
start() Future<void>
Initialize the instance. This method can be called manually or will be called when the first compute() has been made.
stop() Future<void>
Stops and completely terminates the isolate manager instance.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

debugLogPrefix String
Debug logs prefix.
getter/setter pair

Static Methods

addWorkerMapping<R, P>(IsolateFunction<R, P> function, String name, {bool overwrite = false}) → void
Adds a mapping between a function and a Worker.
clearWorkerMappings() → void
Clears all worker mappings.
createShared({int concurrent = 1, bool useWorker = false, Object workerConverter(dynamic)?, Map<Function, String>? workerMappings, bool autoStart = true, String subPath = '', int maxQueueCount = 0, QueueStrategy<Object, List<Object>>? queueStrategy, bool enableWasmConverter = true, bool isDebug = false}) IsolateManagerShared
Create multiple long live isolates for computation. This method can be used to compute multiple functions.
registerException(IsolateExceptionFactory exception) → void
Registers a custom exception type with the IsolateException system.
run<R>(FutureOr<R> computation(), {String? workerName, Object? workerParameter, IsolateConverter<R>? converter, IsolateConverter<R>? workerConverter, bool enableWasmConverter = true, bool isDebug = false}) Future<R>
Executes computation in a one-off isolate and returns its result. This function behaves similarly to Isolate.run but also supports Web Workers.
runCustomFunction<R, P>(IsolateCustomFunction function, P parameter, {String? workerName, IsolateConverter<R>? converter, IsolateConverter<R>? workerConverter, IsolateCallback<R>? callback, bool enableWasmConverter = true, bool isDebug = false}) Future<R>
Executes function in a dedicated, one-off isolate and returns its result.
runFunction<R, P>(IsolateFunction<R, P> function, P parameter, {String? workerName, IsolateConverter<R>? converter, IsolateConverter<R>? workerConverter, bool enableWasmConverter = true, bool isDebug = false}) Future<R>
Executes function in a dedicated, one-off isolate and returns its result.
unregisterException(IsolateExceptionFactory exception) → void
Unregisters a custom exception type from the IsolateException system.