WorkerPool constructor
WorkerPool({
- required WorkerInit onInit,
- int workers = 1,
- DispatchStrategy dispatch = DispatchStrategy.roundRobin,
- SupervisionPolicy supervision = const SupervisionPolicy(),
- int? maxInFlightPerWorker = 64,
- Object? initialData,
- Object? initialDataFor(
- int index
- bool isModelBus = false,
- 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());
}