X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fabstract-worker-choice-strategy.ts;h=cc38d196941e4611af2235a84899cd82ab55c9f0;hb=48e6ef5a44b43a9a8be1c99ef96405af33192e92;hp=4ed7dcae2b0dea882d1eb15a1cb0f88310435e7f;hpb=b1aae69557f4f5c524f665e92882b76f23a19866;p=poolifier.git diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index 4ed7dcae..cc38d196 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -30,10 +30,15 @@ export abstract class AbstractWorkerChoiceStrategy< */ protected nextWorkerNodeKey: number | undefined = 0 + /** + * The previous worker node key. + */ + protected previousWorkerNodeKey: number = 0 + /** @inheritDoc */ public readonly strategyPolicy: StrategyPolicy = { dynamicWorkerUsage: false, - dynamicWorkerReady: false + dynamicWorkerReady: true } /** @inheritDoc */ @@ -199,6 +204,16 @@ export abstract class AbstractWorkerChoiceStrategy< } } + protected checkNextWorkerNodeEligibility ( + chosenWorkerNodeKey: number | undefined + ): void { + if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) { + this.nextWorkerNodeKey = undefined + this.previousWorkerNodeKey = + chosenWorkerNodeKey ?? this.previousWorkerNodeKey + } + } + protected computeDefaultWorkerWeight (): number { let cpusCycleTimeWeight = 0 for (const cpu of cpus()) {