- this.workerOptions.poolOptions.exitHandler = workerOptions?.poolOptions?.exitHandler ?? WorkerUtils.defaultExitHandler;
- this.pool = new DynamicThreadPool<WorkerData>(this.workerOptions.poolMinSize, this.workerOptions.poolMaxSize, this.workerScript, this.workerOptions.poolOptions);
+ this.workerOptions.poolOptions.errorHandler = (
+ this.workerOptions?.poolOptions?.errorHandler ?? WorkerUtils.defaultErrorHandler
+ ).bind(this) as ErrorHandler<Worker>;
+ this.workerOptions.poolOptions.exitHandler = (
+ this.workerOptions?.poolOptions?.exitHandler ?? WorkerUtils.defaultExitHandler
+ ).bind(this) as ExitHandler<Worker>;
+ this.workerOptions.poolOptions.messageHandler.bind(this);
+ this.pool = new DynamicThreadPool<WorkerData>(
+ this.workerOptions.poolMinSize,
+ this.workerOptions.poolMaxSize,
+ this.workerScript,
+ this.workerOptions.poolOptions
+ );