From: Jérôme Benoit Date: Sun, 7 May 2023 17:05:34 +0000 (+0200) Subject: fix: calculate round weights in IWRR at setting worker choice strategy X-Git-Tag: v2.5.0~3^2~44 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e4854a4e8f9738edea289d65c55590e1bf9fe7e7;p=poolifier.git fix: calculate round weights in IWRR at setting worker choice strategy options Signed-off-by: Jérôme Benoit --- 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()) {