X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=836a1cb5052c5f2219e9e872b3a979684b0336af;hb=daa307e54545706359aff24ef409a73eac4a4c11;hp=8290f89ed9a143a8420a45cb1c5965454bebe35e;hpb=10fcfaf49c0b6d6f0e1d137eeba1e9d805c9a815;p=poolifier.git diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index 8290f89e..836a1cb5 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -1,6 +1,6 @@ -import type { AbstractPoolWorker } from '../abstract-pool-worker' import type { IPoolInternal } from '../pool-internal' import { PoolType } from '../pool-internal' +import type { IPoolWorker } from '../pool-worker' import { DynamicPoolWorkerChoiceStrategy } from './dynamic-pool-worker-choice-strategy' import type { IWorkerChoiceStrategy, @@ -17,7 +17,7 @@ import { SelectionStrategiesUtils } from './selection-strategies-utils' * @template Response Type of response of execution. This can only be serializable data. */ export class WorkerChoiceStrategyContext< - Worker extends AbstractPoolWorker, + Worker extends IPoolWorker, Data, Response > { @@ -39,7 +39,7 @@ export class WorkerChoiceStrategyContext< } /** - * Get the worker choice strategy instance specific to the pool type. + * Gets the worker choice strategy instance specific to the pool type. * * @param workerChoiceStrategy The worker choice strategy. * @returns The worker choice strategy instance for the pool type. @@ -61,7 +61,7 @@ export class WorkerChoiceStrategyContext< } /** - * Get the worker choice strategy used in the context. + * Gets the worker choice strategy used in the context. * * @returns The worker choice strategy. */ @@ -70,20 +70,21 @@ export class WorkerChoiceStrategyContext< } /** - * Set the worker choice strategy to use in the context. + * Sets the worker choice strategy to use in the context. * * @param workerChoiceStrategy The worker choice strategy to set. */ public setWorkerChoiceStrategy ( workerChoiceStrategy: WorkerChoiceStrategy ): void { + this.workerChoiceStrategy?.reset() this.workerChoiceStrategy = this.getPoolWorkerChoiceStrategy( workerChoiceStrategy ) } /** - * Choose a worker with the underlying selection strategy. + * Chooses a worker with the underlying selection strategy. * * @returns The chosen one. */