X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fless-busy-worker-choice-strategy.ts;h=f518f9b17f311ad3a8ad262e3b7e5f0be15cc61b;hb=dab8c377b70fc962ec217f2aeb719842f9f94cd6;hp=10fc3bf761f4908d8b1dd402f2ee2161310665f7;hpb=cb70b19deb97dc2c8ad1a769e59e870ee37f8e4d;p=poolifier.git diff --git a/src/pools/selection-strategies/less-busy-worker-choice-strategy.ts b/src/pools/selection-strategies/less-busy-worker-choice-strategy.ts index 10fc3bf7..f518f9b1 100644 --- a/src/pools/selection-strategies/less-busy-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/less-busy-worker-choice-strategy.ts @@ -35,7 +35,7 @@ export class LessBusyWorkerChoiceStrategy< opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS ) { super(pool, opts) - this.checkOptions(this.opts) + this.setRequiredStatistics(this.opts) } /** @inheritDoc */ @@ -43,6 +43,11 @@ export class LessBusyWorkerChoiceStrategy< return true } + /** @inheritDoc */ + public update (): boolean { + return true + } + /** @inheritDoc */ public choose (): number { const freeWorkerNodeKey = this.findFreeWorkerNodeKey() @@ -51,20 +56,20 @@ export class LessBusyWorkerChoiceStrategy< } let minRunTime = Infinity let lessBusyWorkerNodeKey!: number - for (const [index, workerNode] of this.pool.workerNodes.entries()) { + for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) { const workerRunTime = workerNode.tasksUsage.runTime if (workerRunTime === 0) { - return index + return workerNodeKey } else if (workerRunTime < minRunTime) { minRunTime = workerRunTime - lessBusyWorkerNodeKey = index + lessBusyWorkerNodeKey = workerNodeKey } } return lessBusyWorkerNodeKey } /** @inheritDoc */ - public remove (workerNodeKey: number): boolean { + public remove (): boolean { return true } }