1 import type { IPoolWorker
} from
'../pool-worker'
4 * Enumeration of worker choice strategies.
6 export const WorkerChoiceStrategies
= Object.freeze({
8 * Round robin worker selection strategy.
10 ROUND_ROBIN
: 'ROUND_ROBIN',
12 * Less recently used worker selection strategy.
14 LESS_RECENTLY_USED
: 'LESS_RECENTLY_USED',
16 * Fair share worker selection strategy.
18 FAIR_SHARE
: 'FAIR_SHARE',
20 * Weighted round robin worker selection strategy.
22 WEIGHTED_ROUND_ROBIN
: 'WEIGHTED_ROUND_ROBIN'
26 * Worker choice strategy.
28 export type WorkerChoiceStrategy
= keyof
typeof WorkerChoiceStrategies
31 * Pool tasks usage statistics requirements.
33 export interface RequiredStatistics
{
38 * Worker choice strategy interface.
40 * @template Worker Type of worker which manages the strategy.
42 export interface IWorkerChoiceStrategy
<Worker
extends IPoolWorker
> {
44 * Is the pool attached to the strategy dynamic?.
46 readonly isDynamicPool
: boolean
48 * Required pool tasks usage statistics.
50 readonly requiredStatistics
: RequiredStatistics
52 * Resets strategy internals (counters, statistics, etc.).
56 * Chooses a worker in the pool.