X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerStaticPool.ts;h=de1f5b29cfb89aebc39240584f9ed045ee6b1efb;hb=baa539e6b66a5c479327f48195df5a4133b8c0e7;hp=2dd2bc8095dd15c8ccf399df2eaee695cbc14190;hpb=78202038ffd2aca15aa97f45bc66ba42f40f2ec4;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerStaticPool.ts b/src/worker/WorkerStaticPool.ts index 2dd2bc80..de1f5b29 100644 --- a/src/worker/WorkerStaticPool.ts +++ b/src/worker/WorkerStaticPool.ts @@ -1,13 +1,12 @@ -import type { Worker } from 'worker_threads'; +import type { Worker } from 'node:worker_threads'; import { type ErrorHandler, type ExitHandler, FixedThreadPool } from 'poolifier'; -import WorkerAbstract from './WorkerAbstract'; +import { WorkerAbstract } from './WorkerAbstract'; +import type { WorkerData, WorkerOptions } from './WorkerTypes'; import { WorkerUtils } from './WorkerUtils'; -import type { WorkerData, WorkerOptions } from '../types/Worker'; -import Utils from '../utils/Utils'; -export default class WorkerStaticPool extends WorkerAbstract { +export class WorkerStaticPool extends WorkerAbstract { private readonly pool: FixedThreadPool; /** @@ -33,11 +32,11 @@ export default class WorkerStaticPool extends WorkerAbstract { } get size(): number { - return this.pool.workers.length; + return this.pool.workerNodes.length; } - get maxElementsPerWorker(): number | null { - return null; + get maxElementsPerWorker(): number | undefined { + return undefined; } /** @@ -68,6 +67,6 @@ export default class WorkerStaticPool extends WorkerAbstract { await this.pool.execute(elementData); // Start element sequentially to optimize memory at startup this.workerOptions.elementStartDelay > 0 && - (await Utils.sleep(this.workerOptions.elementStartDelay)); + (await WorkerUtils.sleep(this.workerOptions.elementStartDelay)); } }