From f8eb0a2ac2b5c65b09e1488f277237dd3268e552 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 30 May 2023 12:44:00 +0200 Subject: [PATCH] refactor: silence sonar MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 2e769fc9..724785f5 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -430,13 +430,21 @@ export abstract class AbstractPool< worker: Worker, message: MessageValue ): void { - const workerNodeKey = this.getWorkerNodeKey(worker) - const workerTasksUsage = this.workerNodes[workerNodeKey].tasksUsage + const workerTasksUsage = + this.workerNodes[this.getWorkerNodeKey(worker)].tasksUsage --workerTasksUsage.running ++workerTasksUsage.run if (message.error != null) { ++workerTasksUsage.error } + this.updateRunTimeTasksUsage(workerTasksUsage, message) + this.updateWaitTasksUsage(workerTasksUsage, message) + } + + private updateRunTimeTasksUsage ( + workerTasksUsage: TasksUsage, + message: MessageValue + ): void { if (this.workerChoiceStrategyContext.getRequiredStatistics().runTime) { workerTasksUsage.runTime += message.runTime ?? 0 if ( @@ -454,6 +462,12 @@ export abstract class AbstractPool< workerTasksUsage.medRunTime = median(workerTasksUsage.runTimeHistory) } } + } + + private updateWaitTasksUsage ( + workerTasksUsage: TasksUsage, + message: MessageValue + ): void { if (this.workerChoiceStrategyContext.getRequiredStatistics().waitTime) { workerTasksUsage.waitTime += message.waitTime ?? 0 if ( -- 2.34.1