2 * Enumeration of worker choice strategies.
4 export const WorkerChoiceStrategies
= Object.freeze({
6 * Round robin worker selection strategy.
8 ROUND_ROBIN
: 'ROUND_ROBIN',
10 * Less used worker selection strategy.
12 LESS_USED
: 'LESS_USED',
14 * Less busy worker selection strategy.
16 LESS_BUSY
: 'LESS_BUSY',
18 * Fair share worker selection strategy.
20 FAIR_SHARE
: 'FAIR_SHARE',
22 * Weighted round robin worker selection strategy.
24 WEIGHTED_ROUND_ROBIN
: 'WEIGHTED_ROUND_ROBIN'
28 * Worker choice strategy.
30 export type WorkerChoiceStrategy
= keyof
typeof WorkerChoiceStrategies
33 * Pool worker tasks usage statistics requirements.
35 export interface RequiredStatistics
{
41 * Worker choice strategy interface.
43 export interface IWorkerChoiceStrategy
{
45 * Required pool tasks usage statistics.
47 readonly requiredStatistics
: RequiredStatistics
49 * Resets strategy internals (counters, statistics, etc.).
53 * Chooses a worker in the pool and returns its key.
57 * Removes a worker reference from strategy internals.
59 * @param workerKey - The worker key.
61 remove
: (workerKey
: number) => boolean