From: Jakob Date: Thu, 21 Jan 2021 14:59:25 +0000 (+0100) Subject: renaming (pool size != max pool size) X-Git-Tag: v1.0.1-0~132 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=72a965c4c1a907dfee70da0c97e88c221eefdebc;p=e-mobility-charging-stations-simulator.git renaming (pool size != max pool size) --- diff --git a/docker/config.json b/docker/config.json index edd0da85..84148c20 100644 --- a/docker/config.json +++ b/docker/config.json @@ -5,7 +5,8 @@ "distributeStationsToTenantsEqually": true, "statisticsDisplayInterval": 60, "useWorkerPool": false, - "workerPoolSize": 16, + "workerMaxPoolSize": 16, + "chargingStationsPerWorker": 1, "stationTemplateURLs": [ { "file": "./src/assets/station-templates/siemens.station-template.json", diff --git a/src/assets/config-template.json b/src/assets/config-template.json index bfa96ecc..e6ea2f33 100644 --- a/src/assets/config-template.json +++ b/src/assets/config-template.json @@ -5,7 +5,7 @@ "distributeStationsToTenantsEqually": true, "statisticsDisplayInterval": 60, "useWorkerPool": false, - "workerPoolSize": 16, + "workerMaxPoolSize": 16, "chargingStationsPerWorker": 1, "stationTemplateURLs": [ { diff --git a/src/charging-station/Worker.ts b/src/charging-station/Worker.ts index efa327fd..66e21329 100644 --- a/src/charging-station/Worker.ts +++ b/src/charging-station/Worker.ts @@ -20,7 +20,7 @@ export default class Wrk { this._workerData = workerData; this._workerScript = workerScript; if (Configuration.useWorkerPool()) { - WorkerPool.maxConcurrentWorkers = Configuration.getWorkerPoolSize(); + WorkerPool.maxConcurrentWorkers = Configuration.getWorkerMaxPoolSize(); } } @@ -88,8 +88,18 @@ export default class Wrk { this._worker = worker; }); } + + /** + * + * @return {number} + * @public + */ + public getPoolSize(): number { + return WorkerPool.getPoolSize(); + } } + class WorkerPool { public static maxConcurrentWorkers: number; private static _instance: Pool; @@ -106,4 +116,8 @@ class WorkerPool { public static acquire(filename: string, options: WorkerOptions, callback: (error: Error | null, worker: Worker) => void): void { WorkerPool.getInstance().acquire(filename, options, callback); } + + public static getPoolSize(): number { + return WorkerPool._instance.size; + } } diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index bc4e0f88..604e249b 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -11,7 +11,7 @@ export default interface ConfigurationData { autoReconnectMaxRetries?: number; distributeStationsToTenantsEqually?: boolean; useWorkerPool?: boolean; - workerPoolSize?: number; + workerMaxPoolSize?: number; chargingStationsPerWorker?: number; logFormat?: string; logLevel?: string; diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 3e2a66bc..eb1992b3 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -41,8 +41,8 @@ export default class Configuration { return Configuration.getConfig().useWorkerPool; } - static getWorkerPoolSize(): number { - return Configuration.getConfig().workerPoolSize; + static getWorkerMaxPoolSize(): number { + return Configuration.getConfig().workerMaxPoolSize; } static getChargingStationsPerWorker(): number {