X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fselection-strategies-types.ts;h=3e7c3427e84f7bedb015e8f6d7ef54215377bd40;hb=4e94da3a0cd5bfe961c73babead4262134f8770f;hp=359cfb948c6334dc507a3d0894149790aef584f9;hpb=b3432a63039e7cb70c0448da5518690e457cd47e;p=poolifier.git diff --git a/src/pools/selection-strategies/selection-strategies-types.ts b/src/pools/selection-strategies/selection-strategies-types.ts index 359cfb94..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. @@ -12,6 +12,10 @@ export const WorkerChoiceStrategies = Object.freeze({ * Less recently used worker selection strategy. */ LESS_RECENTLY_USED: 'LESS_RECENTLY_USED', + /** + * Fair share worker selection strategy. + */ + FAIR_SHARE: 'FAIR_SHARE', /** * Weighted round robin worker selection strategy. */ @@ -23,18 +27,33 @@ export const WorkerChoiceStrategies = Object.freeze({ */ export type WorkerChoiceStrategy = keyof typeof WorkerChoiceStrategies +/** + * Pool tasks usage statistics requirements. + */ +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 pool tasks usage statistics. + */ + readonly requiredStatistics: RequiredStatistics + /** + * Resets strategy internals (counters, statistics, etc.). + */ + reset: () => boolean /** - * Choose a worker in the pool. + * Chooses a worker in the pool. */ - choose(): Worker + choose: () => Worker }