X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fworker%2FWorkerStaticPool.ts;h=c78768e01360a788f131029025433ee8590a5f9b;hb=322c9192eaa7142da1bf475cc2c6588ca72d922c;hp=6421762918cc1ce9986a277cb1e46e58a5e16ccc;hpb=99503026b3fc316b7743d55a7e5c1c814bc43499;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerStaticPool.ts b/src/worker/WorkerStaticPool.ts index 64217629..c78768e0 100644 --- a/src/worker/WorkerStaticPool.ts +++ b/src/worker/WorkerStaticPool.ts @@ -1,6 +1,5 @@ import { FixedThreadPool, PoolOptions } from 'poolifier'; -import Constants from '../utils/Constants'; import Utils from '../utils/Utils'; import { Worker } from 'worker_threads'; import WorkerAbstract from './WorkerAbstract'; @@ -14,9 +13,10 @@ export default class WorkerStaticPool extends WorkerAbstract { * * @param {string} workerScript * @param {number} numberOfThreads + * @param {number} startWorkerDelay */ - constructor(workerScript: string, numberOfThreads: number) { - super(workerScript); + constructor(workerScript: string, numberOfThreads: number, startWorkerDelay?: number) { + super(workerScript, startWorkerDelay); this.pool = StaticPool.getInstance(numberOfThreads, this.workerScript); } @@ -54,7 +54,7 @@ export default class WorkerStaticPool extends WorkerAbstract { public async addElement(elementData: T): Promise { await this.pool.execute(elementData); // Start worker sequentially to optimize memory at startup - await Utils.sleep(Constants.START_WORKER_DELAY); + await Utils.sleep(this.workerStartDelay); } }