X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fweighted-round-robin-worker-choice-strategy.ts;h=9ee4fa656632c7fcdfc982e5b7cf40b794d57e97;hb=e65c6cd9a3d6ed2e5b8af95120a5aa070101e945;hp=1af7e6568f19a0705df40014ff404e91645dfd09;hpb=d4abc60abeea2538c1452ae6d8bd2463bdacc910;p=poolifier.git 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 1af7e656..9ee4fa65 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 @@ -67,8 +67,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< /** {@inheritDoc} */ public choose (): Worker { - const chosenWorker = this.pool.workers.get(this.currentWorkerId) - ?.worker as Worker + const chosenWorker = this.pool.workers[this.currentWorkerId]?.worker if (this.isDynamicPool && !this.workersTaskRunTime.has(chosenWorker)) { this.initWorkerTaskRunTime(chosenWorker) } @@ -86,11 +85,11 @@ export class WeightedRoundRobinWorkerChoiceStrategy< ) } else { this.currentWorkerId = - this.currentWorkerId === this.pool.workers.size - 1 + this.currentWorkerId === this.pool.workers.length - 1 ? 0 : this.currentWorkerId + 1 this.setWorkerTaskRunTime( - this.pool.workers.get(this.currentWorkerId)?.worker as Worker, + this.pool.workers[this.currentWorkerId]?.worker, workerTaskWeight, 0 ) @@ -99,8 +98,8 @@ export class WeightedRoundRobinWorkerChoiceStrategy< } private initWorkersTaskRunTime (): void { - for (const value of this.pool.workers.values()) { - this.initWorkerTaskRunTime(value.worker) + for (const workerItem of this.pool.workers) { + this.initWorkerTaskRunTime(workerItem.worker) } }