X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerFactory.ts;h=2d923daab084bb95b77a783509053bed4b519a7a;hb=059f35a55515a998352f621e40a1e35bd22b424d;hp=067188d846401d13c3a76c1bdff6236442de6859;hpb=144cabe085e5e1f3821aecb2ef8f388a1030b92b;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index 067188d8..2d923daa 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -1,13 +1,21 @@ import Configuration from '../utils/Configuration'; -import WorkerPool from './WorkerPool'; +import WorkerDynamicPool from './WorkerDynamicPool'; +import { WorkerProcessType } from '../types/Worker'; import WorkerSet from './WorkerSet'; +import WorkerStaticPool from './WorkerStaticPool'; import Wrk from './Wrk'; export default class WorkerFactory { public static getWorkerImpl(workerScript: string): Wrk { - if (Configuration.useWorkerPool()) { - return new WorkerPool(workerScript); + switch (Configuration.getWorkerProcess()) { + case WorkerProcessType.WORKER_SET: + return new WorkerSet(workerScript, Configuration.getChargingStationsPerWorker()); + case WorkerProcessType.STATIC_POOL: + return new WorkerStaticPool(workerScript, Configuration.getWorkerPoolMaxSize()); + case WorkerProcessType.DYNAMIC_POOL: + return new WorkerDynamicPool(workerScript, Configuration.getWorkerPoolMinSize(), Configuration.getWorkerPoolMaxSize()); + default: + return null; } - return new WorkerSet(workerScript, Configuration.getChargingStationsPerWorker()); } }