WorkerPool constructor

WorkerPool({
  1. required WorkerInit onInit,
  2. int workers = 1,
  3. DispatchStrategy dispatch = DispatchStrategy.roundRobin,
  4. SupervisionPolicy supervision = const SupervisionPolicy(),
  5. int? maxInFlightPerWorker = 64,
  6. Object? initialData,
  7. Object? initialDataFor(
    1. int index
    )?,
  8. bool isModelBus = false,
  9. WorkerKeySelector? keySelector,
})

Implementation

WorkerPool({
  required this.onInit,
  this.workers = 1,
  this.dispatch = DispatchStrategy.roundRobin,
  this.supervision = const SupervisionPolicy(),
  this.maxInFlightPerWorker = 64,
  this.initialData,
  this.initialDataFor,
  this.isModelBus = false,
  this.keySelector,
}) {
  _requireIsolates('WorkerPool');
  if (workers < 1) {
    throw ArgumentError.value(workers, 'workers', 'must be >= 1');
  }
  if (maxInFlightPerWorker != null && maxInFlightPerWorker! < 1) {
    throw ArgumentError.value(
        maxInFlightPerWorker, 'maxInFlightPerWorker', 'must be null or >= 1');
  }
  for (var index = 0; index < workers; index++) {
    _slots.add(_WorkerSlot(index));
  }
  // A caller that never awaits waitInit must not turn a start failure into an
  // unhandled zone error; listeners of waitInit still receive the error.
  _initialReady.future.ignore();
  unawaited(_start());
}