From 1399f8588a401fd8d4e146da7a31fd6444e31021 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 8 Oct 2022 13:33:22 +0200 Subject: [PATCH] Keep the LRU strategy implementation as optimized as it was MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../less-recently-used-worker-choice-strategy.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pools/selection-strategies/less-recently-used-worker-choice-strategy.ts b/src/pools/selection-strategies/less-recently-used-worker-choice-strategy.ts index a7892c40..33f6859c 100644 --- a/src/pools/selection-strategies/less-recently-used-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/less-recently-used-worker-choice-strategy.ts @@ -19,13 +19,12 @@ export class LessRecentlyUsedWorkerChoiceStrategy< // A worker is always found because it picks the one with fewer tasks let lessRecentlyUsedWorker!: Worker for (const worker of this.pool.workers) { - const workerRunningTasks = this.pool.getWorkerRunningTasks(worker) - if (!this.isDynamicPool && workerRunningTasks === 0) { + const workerRunningTasks = this.pool.getWorkerRunningTasks( + worker + ) as number + if (this.isDynamicPool === false && workerRunningTasks === 0) { return worker - } else if ( - workerRunningTasks !== undefined && - workerRunningTasks < minNumberOfRunningTasks - ) { + } else if (workerRunningTasks < minNumberOfRunningTasks) { lessRecentlyUsedWorker = worker minNumberOfRunningTasks = workerRunningTasks } -- 2.34.1