IsolateManager<R, P>.createCustom constructor

IsolateManager<R, P>.createCustom(
  1. IsolateCustomFunction isolateFunction, {
  2. String? workerName,
  3. String debugName = 'custom',
  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 instance with a custom isolate function.

isolateFunction is the user-defined 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:

Set isDebug to true to enable debug logs.

Implementation

IsolateManager.createCustom(
  IsolateCustomFunction this.isolateFunction, {
  String? workerName,
  String debugName = 'custom',
  this.concurrent = 1,
  this.converter,
  this.workerConverter,
  QueueStrategy<R, P>? queueStrategy,
  this.enableWasmConverter = true,
  this.enableWasmTransferables = false,
  this.isDebug = false,
}) : isCustomIsolate = true,
     queueStrategy = queueStrategy ?? UnlimitedStrategy(),
     _debugName = debugName,
     _workerName = normalizePath(workerName) {
  // Set the debug log prefix.
  IsolateContactor.debugLogPrefix = debugLogPrefix;
}