IsolateManager<R, P>.create constructor

IsolateManager<R, P>.create(
  1. IsolateFunction<R, P> isolateFunction, {
  2. String? workerName,
  3. String debugName = 'normal',
  4. int concurrent = 1,
  5. IsolateConverter<R>? converter,
  6. IsolateConverter<R>? workerConverter,
  7. QueueStrategy<R, P>? queueStrategy,
  8. bool enableWasmConverter = true,
  9. bool enableWasmTransferables = false,
  10. bool isDebug = false,
})

Creates a new IsolateManager for isolate-based computations.

isolateFunction is the function to be run in each isolate.

Use workerName (or a pre-defined mapping in _workerMappings) to utilize a named worker JS file on the Web.

concurrent decides how many isolates to spawn.

Transforms results using converter and workerConverter before returning them.

When enableWasmConverter is true (default), the int type is automatically converted back to its intended type during message passing between web workers. This ensures proper type handling in WebAssembly environments.

The conversion pipeline applies WASM conversions first, then passes results through any custom converter functions provided.

When enableWasmTransferables is false (default), transferables are omitted when targeting WebAssembly (WASM) to avoid unnecessary overhead, as WASM does not benefit from zero-copy transfers. Set to true to force the use of transferables even on WASM.

Control the Queue strategy via queueStrategy with the following basic strategies:

isDebug enables debug logs when set to true.

Implementation

IsolateManager.create(
  IsolateFunction<R, P> this.isolateFunction, {
  String? workerName,
  String debugName = 'normal',
  this.concurrent = 1,
  this.converter,
  this.workerConverter,
  QueueStrategy<R, P>? queueStrategy,
  this.enableWasmConverter = true,
  this.enableWasmTransferables = false,
  this.isDebug = false,
}) : isCustomIsolate = false,
     queueStrategy = queueStrategy ?? UnlimitedStrategy(),
     _debugName = debugName,
     _workerName = normalizePath(workerName) {
  IsolateContactor.debugLogPrefix = debugLogPrefix;
}