X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerStaticPool.ts;h=392981237289a78044af6d3a0cd8830eb6888210;hb=b2b606263e2676354259164d532ff9aa91ccdf87;hp=f5c2a6e89f60658dc0e30082d4aea62ad8e0ad62;hpb=d58b442097da31f8b974d51aef63c64470d9ab48;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerStaticPool.ts b/src/worker/WorkerStaticPool.ts index f5c2a6e8..39298123 100644 --- a/src/worker/WorkerStaticPool.ts +++ b/src/worker/WorkerStaticPool.ts @@ -1,30 +1,20 @@ -import type EventEmitterAsyncResource from 'node:events'; -import type { Worker } from 'node:worker_threads'; - -import { type ErrorHandler, type ExitHandler, FixedThreadPool, type PoolInfo } from 'poolifier'; +import { FixedThreadPool, type PoolEmitter, type PoolInfo } from 'poolifier'; import { WorkerAbstract } from './WorkerAbstract'; import type { WorkerData, WorkerOptions } from './WorkerTypes'; -import { defaultErrorHandler, defaultExitHandler, sleep } from './WorkerUtils'; +import { sleep } from './WorkerUtils'; export class WorkerStaticPool extends WorkerAbstract { private readonly pool: FixedThreadPool; /** - * Create a new `WorkerStaticPool`. + * Creates a new `WorkerStaticPool`. * * @param workerScript - * @param workerOptions - */ constructor(workerScript: string, workerOptions?: WorkerOptions) { super(workerScript, workerOptions); - this.workerOptions.poolOptions.errorHandler = ( - this.workerOptions?.poolOptions?.errorHandler ?? defaultErrorHandler - ).bind(this) as ErrorHandler; - this.workerOptions.poolOptions.exitHandler = ( - this.workerOptions?.poolOptions?.exitHandler ?? defaultExitHandler - ).bind(this) as ExitHandler; - this.workerOptions.poolOptions.messageHandler.bind(this); this.pool = new FixedThreadPool( this.workerOptions.poolMaxSize, this.workerScript, @@ -44,7 +34,7 @@ export class WorkerStaticPool extends WorkerAbstract { return undefined; } - get emitter(): EventEmitterAsyncResource | undefined { + get emitter(): PoolEmitter | undefined { return this.pool?.emitter; }