-import type { AbstractPoolWorker } from '../abstract-pool-worker'
+import type { IPoolWorker } from '../pool-worker'
/**
* Enumeration of worker choice strategies.
* 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.
*/
*/
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<Worker extends AbstractPoolWorker> {
+export interface IWorkerChoiceStrategy<Worker extends IPoolWorker> {
/**
* 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
}