From: Jérôme Benoit Date: Sat, 8 Oct 2022 11:33:22 +0000 (+0200) Subject: Keep the LRU strategy implementation as optimized as it was X-Git-Tag: v2.2.1~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1399f8588a401fd8d4e146da7a31fd6444e31021;p=poolifier.git Keep the LRU strategy implementation as optimized as it was Signed-off-by: Jérôme Benoit --- 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 }