X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=711a71bedb25205bef8b1fdbdaf4528866e92879;hb=41e3e08eb7fbcde0a69cea17e697aacb222990a6;hp=cc028fecf45d7e3106b09cd0028a55e977e284b9;hpb=303e7a50f248cab49326efe53cc6f93569ad2b20;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index cc028fec..711a71be 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 } /** @@ -125,20 +135,34 @@ export interface TasksQueueOptions { export interface PoolOptions { /** * A function that will listen for online event on each worker. + * + * @defaultValue `() => {}` */ onlineHandler?: OnlineHandler /** * A function that will listen for message event on each worker. + * + * @defaultValue `() => {}` */ messageHandler?: MessageHandler /** * A function that will listen for error event on each worker. + * + * @defaultValue `() => {}` */ errorHandler?: ErrorHandler /** * A function that will listen for exit event on each worker. + * + * @defaultValue `() => {}` */ exitHandler?: ExitHandler + /** + * Whether to start the minimum number of workers at pool initialization. + * + * @defaultValue true + */ + startWorkers?: boolean /** * The worker choice strategy to use in this pool. * @@ -207,7 +231,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 +252,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. */