X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=b5eec21c714798099076be2dab22f64aec4722ac;hb=9d21ee7f84ab8b3960745f0be0a629a427e101f0;hp=cc028fecf45d7e3106b09cd0028a55e977e284b9;hpb=92cd01a6c5424711965caa659f025ecfcee1654c;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index cc028fec..b5eec21c 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -63,6 +63,7 @@ export interface PoolInfo { readonly version: string readonly type: PoolType readonly worker: WorkerType + readonly started: boolean readonly ready: boolean readonly strategy: WorkerChoiceStrategy readonly minSize: number @@ -80,6 +81,7 @@ export interface PoolInfo { readonly queuedTasks?: number readonly maxQueuedTasks?: number readonly backPressure?: boolean + readonly stolenTasks?: number readonly failedTasks: number readonly runTime?: { readonly minimum: number @@ -105,16 +107,24 @@ export interface TasksQueueOptions { * @defaultValue (pool maximum size)^2 */ readonly size?: number - /** - * @deprecated Use `size` instead. - */ - readonly queueMaxSize?: number /** * Maximum number of tasks that can be executed concurrently on a worker node. * * @defaultValue 1 */ readonly concurrency?: number + /** + * Whether to enable task stealing. + * + * @defaultValue true + */ + readonly taskStealing?: boolean + /** + * Whether to enable tasks stealing on back pressure. + * + * @defaultValue true + */ + readonly tasksStealingOnBackPressure?: boolean } /** @@ -139,6 +149,12 @@ export interface PoolOptions { * A function that will listen for exit event on each worker. */ exitHandler?: ExitHandler + /** + * Whether to start the minimum number of workers at pool initialization. + * + * @defaultValue false + */ + startWorkers?: boolean /** * The worker choice strategy to use in this pool. * @@ -207,7 +223,7 @@ export interface IPool< * Events that can currently be listened to: * * - `'ready'`: Emitted when the number of workers created in the pool has reached the minimum size expected and are ready. - * - `'busy'`: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing at least one task. + * - `'busy'`: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing concurrently their tasks quota. * - `'full'`: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected. * - `'destroy'`: Emitted when the pool is destroyed. * - `'error'`: Emitted when an uncaught error occurs. @@ -228,6 +244,10 @@ export interface IPool< name?: string, transferList?: TransferListItem[] ) => Promise + /** + * Starts the minimum number of workers in this pool. + */ + readonly start: () => void /** * Terminates all workers in this pool. */