X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerStaticPool.ts;h=acc61b8fad0fadac0fa66a7f7433a9e143db4658;hb=6d52ef25c911dcb8d37ead86819b53a7fe35ef53;hp=e49ac2613e97e0da7dc7857b7ec2a4b3cf3f2fd1;hpb=361c98f57255e5b91d123d5f2ba43ab533134b1a;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerStaticPool.ts b/src/worker/WorkerStaticPool.ts index e49ac261..acc61b8f 100644 --- a/src/worker/WorkerStaticPool.ts +++ b/src/worker/WorkerStaticPool.ts @@ -1,6 +1,4 @@ -import type EventEmitterAsyncResource from 'node:events'; - -import { FixedThreadPool, type PoolInfo } from 'poolifier'; +import { FixedThreadPool, type PoolEmitter, type PoolInfo } from 'poolifier'; import { WorkerAbstract } from './WorkerAbstract'; import type { WorkerData, WorkerOptions } from './WorkerTypes'; @@ -15,12 +13,12 @@ export class WorkerStaticPool extends WorkerAbstract { * @param workerScript - * @param workerOptions - */ - constructor(workerScript: string, workerOptions?: WorkerOptions) { + constructor(workerScript: string, workerOptions: WorkerOptions) { super(workerScript, workerOptions); this.pool = new FixedThreadPool( this.workerOptions.poolMaxSize, this.workerScript, - this.workerOptions.poolOptions + this.workerOptions.poolOptions, ); } @@ -36,7 +34,7 @@ export class WorkerStaticPool extends WorkerAbstract { return undefined; } - get emitter(): EventEmitterAsyncResource | undefined { + get emitter(): PoolEmitter | undefined { return this.pool?.emitter; } @@ -54,6 +52,7 @@ export class WorkerStaticPool extends WorkerAbstract { public async addElement(elementData: WorkerData): Promise { await this.pool.execute(elementData); // Start element sequentially to optimize memory at startup - this.workerOptions.elementStartDelay > 0 && (await sleep(this.workerOptions.elementStartDelay)); + this.workerOptions.elementStartDelay! > 0 && + (await sleep(this.workerOptions.elementStartDelay!)); } }