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 used worker selection strategy.
14 LESS_USED
: 'LESS_USED',
16 * Less busy worker selection strategy.
18 LESS_BUSY
: 'LESS_BUSY',
20 * Fair share worker selection strategy.
22 FAIR_SHARE
: 'FAIR_SHARE',
24 * Weighted round robin worker selection strategy.
26 WEIGHTED_ROUND_ROBIN
: 'WEIGHTED_ROUND_ROBIN'
30 * Worker choice strategy.
32 export type WorkerChoiceStrategy
= keyof
typeof WorkerChoiceStrategies
35 * Pool tasks usage statistics requirements.
37 export interface RequiredStatistics
{
42 * Worker choice strategy interface.
44 * @typeParam Worker - Type of worker which manages the strategy.
46 export interface IWorkerChoiceStrategy
<Worker
extends IPoolWorker
> {
48 * Is the pool attached to the strategy dynamic?.
50 readonly isDynamicPool
: boolean
52 * Required pool tasks usage statistics.
54 readonly requiredStatistics
: RequiredStatistics
56 * Resets strategy internals (counters, statistics, etc.).
60 * Chooses a worker in the pool.