X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=3c660031fb90b233bb93125331c81e53200b6803;hb=765457872257684691f93befb94175a2aaa83502;hp=8a5e505f4f2d23909db36ef3d66e987eee9e9afd;hpb=fc3e65861bc1939ae047ee1e8e91a1ce577035f4;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index 8a5e505f..3c660031 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -4,14 +4,30 @@ import type { ExitHandler, MessageHandler, OnlineHandler -} from './pool-worker' -import type { WorkerChoiceStrategy } from './selection-strategies/selection-strategies-types' +} from './worker' +import type { + WorkerChoiceStrategy, + WorkerChoiceStrategyOptions +} from './selection-strategies/selection-strategies-types' /** * Pool events emitter. */ export class PoolEmitter extends EventEmitter {} +/** + * Enumeration of pool events. + */ +export const PoolEvents = Object.freeze({ + full: 'full', + busy: 'busy' +} as const) + +/** + * Pool event. + */ +export type PoolEvent = keyof typeof PoolEvents + /** * Options for a poolifier pool. */ @@ -36,12 +52,23 @@ export interface PoolOptions { * The worker choice strategy to use in this pool. */ workerChoiceStrategy?: WorkerChoiceStrategy + /** + * The worker choice strategy options. + */ + workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions /** * Pool events emission. * * @defaultValue true */ enableEvents?: boolean + /** + * Pool worker tasks queue. + * + * @experimental + * @defaultValue false + */ + enableTasksQueue?: boolean } /** @@ -56,7 +83,8 @@ export interface IPool { * * Events that can currently be listened to: * - * - `'busy'` + * - `'full'`: Emitted when the pool is dynamic and full. + * - `'busy'`: Emitted when the pool is busy. */ readonly emitter?: PoolEmitter /**