X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fselection-strategies-types.ts;h=3e7c3427e84f7bedb015e8f6d7ef54215377bd40;hb=b4e757784e2b9ffe2c22b65b21e8bf665abd9f56;hp=4d302f3defb1e7d5619d37693daf4104c944f377;hpb=10fcfaf49c0b6d6f0e1d137eeba1e9d805c9a815;p=poolifier.git diff --git a/src/pools/selection-strategies/selection-strategies-types.ts b/src/pools/selection-strategies/selection-strategies-types.ts index 4d302f3d..3e7c3427 100644 --- a/src/pools/selection-strategies/selection-strategies-types.ts +++ b/src/pools/selection-strategies/selection-strategies-types.ts @@ -1,4 +1,4 @@ -import type { AbstractPoolWorker } from '../abstract-pool-worker' +import type { IPoolWorker } from '../pool-worker' /** * Enumeration of worker choice strategies. @@ -28,28 +28,32 @@ export const WorkerChoiceStrategies = Object.freeze({ export type WorkerChoiceStrategy = keyof typeof WorkerChoiceStrategies /** - * Tasks usage statistics requirements. + * Pool tasks usage statistics requirements. */ -export type RequiredStatistics = { +export interface RequiredStatistics { runTime: boolean } /** * Worker choice strategy interface. * - * @template Worker Type of worker which manages the strategy. + * @typeParam Worker - Type of worker which manages the strategy. */ -export interface IWorkerChoiceStrategy { +export interface IWorkerChoiceStrategy { /** * Is the pool attached to the strategy dynamic?. */ - isDynamicPool: boolean + readonly isDynamicPool: boolean /** - * Required tasks usage statistics. + * Required pool tasks usage statistics. */ - requiredStatistics: RequiredStatistics + readonly requiredStatistics: RequiredStatistics /** - * Choose a worker in the pool. + * Resets strategy internals (counters, statistics, etc.). */ - choose(): Worker + reset: () => boolean + /** + * Chooses a worker in the pool. + */ + choose: () => Worker }