From e4854a4e8f9738edea289d65c55590e1bf9fe7e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 7 May 2023 19:05:34 +0200 Subject: [PATCH] fix: calculate round weights in IWRR at setting worker choice strategy options MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ...rleaved-weighted-round-robin-worker-choice-strategy.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 09598355..44d4689f 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -42,7 +42,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< /** * Round weights. */ - private readonly roundWeights: number[] + private roundWeights: number[] /** * Default worker weight. */ @@ -132,6 +132,12 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< return true } + /** @inheritDoc */ + public setOptions (opts: WorkerChoiceStrategyOptions): void { + super.setOptions(opts) + this.roundWeights = this.getRoundWeights() + } + private computeDefaultWorkerWeight (): number { let cpusCycleTimeWeight = 0 for (const cpu of cpus()) { -- 2.34.1