From: Jérôme Benoit Date: Fri, 14 Oct 2022 21:50:25 +0000 (+0200) Subject: WRR strategy: cleanups X-Git-Tag: v2.3.2~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=553ad720b4ca65b39e5026fa37f07c5e04aa11b8;p=poolifier.git WRR strategy: cleanups Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index 2b9cfc745..380331321 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -77,19 +77,18 @@ export class WeightedRoundRobinWorkerChoiceStrategy< const workerTaskWeight = this.workersTaskRunTime.get(chosenWorker)?.weight ?? this.defaultWorkerWeight - if ( - (this.workersTaskRunTime.get(chosenWorker)?.runTime ?? 0) < - workerTaskWeight - ) { + const workerTaskRunTime = + this.workersTaskRunTime.get(chosenWorker)?.runTime ?? 0 + if (workerTaskRunTime < workerTaskWeight) { this.setWorkerTaskRunTime( chosenWorker, workerTaskWeight, - (this.workersTaskRunTime.get(chosenWorker)?.runTime ?? 0) + + workerTaskRunTime + (this.getWorkerVirtualTaskRunTime(chosenWorker) ?? 0) ) } else { this.currentWorkerIndex = - this.pool.workers.length - 1 === this.currentWorkerIndex + this.currentWorkerIndex === this.pool.workers.length - 1 ? 0 : this.currentWorkerIndex + 1 chosenWorker = this.pool.workers[this.currentWorkerIndex]