- constructor(workerScript: string, min: number, max: number,) {
- super(workerScript);
- this.pool = DynamicPool.getInstance(min, max, this.workerScript);
+ constructor(workerScript: string, workerOptions?: WorkerOptions) {
+ super(workerScript, workerOptions);
+ this.workerOptions.poolOptions.errorHandler =
+ this.workerOptions?.poolOptions?.errorHandler ?? WorkerUtils.defaultErrorHandler;
+ this.workerOptions.poolOptions.exitHandler =
+ this.workerOptions?.poolOptions?.exitHandler ?? WorkerUtils.defaultExitHandler;
+ this.pool = new DynamicThreadPool<WorkerData>(
+ this.workerOptions.poolMinSize,
+ this.workerOptions.poolMaxSize,
+ this.workerScript,
+ this.workerOptions.poolOptions
+ );