From 0682ba158c6af9ffc453f38bd7d16438eab97695 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 6 May 2023 21:10:58 +0200 Subject: [PATCH] docs: update changelog MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 5 +++++ .../abstract-worker-choice-strategy.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2a0b95f..6c56fd72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use O(1) queue implementation for tasks queueing. +### Fixed + +- Fix median computation implementation. +- Fix fair share worker choice strategy internals update. + ## [2.4.11] - 2023-04-23 ### Changed diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index e2dd626d..bf67b80e 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -124,9 +124,13 @@ export abstract class AbstractWorkerChoiceStrategy< // return this.workerNodes.findLastIndex(workerNode => { // return workerNode.tasksUsage.running === 0 // }) - for (let i = this.pool.workerNodes.length - 1; i >= 0; i--) { - if (this.pool.workerNodes[i].tasksUsage.running === 0) { - return i + for ( + let workerNodeKey = this.pool.workerNodes.length - 1; + workerNodeKey >= 0; + workerNodeKey-- + ) { + if (this.pool.workerNodes[workerNodeKey].tasksUsage.running === 0) { + return workerNodeKey } } return -1 -- 2.34.1