X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=e65cc115d2d77c0a0590fa5f936043b16dcb38d2;hb=8cc4ea811611b8ad77c7b0379911afe497f2e7e4;hp=f4d9c7bba67d18d3c48a212159bf606fe409cfcf;hpb=fd04474e1c355504be97747915708645fd338b6c;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index f4d9c7bb..e65cc115 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -47,7 +47,8 @@ export const PoolEvents = Object.freeze({ full: 'full', destroy: 'destroy', error: 'error', - taskError: 'taskError' + taskError: 'taskError', + backPressure: 'backPressure' } as const) /** @@ -177,8 +178,18 @@ export interface IPool< readonly info: PoolInfo /** * Pool worker nodes. + * + * @internal */ readonly workerNodes: Array> + /** + * Whether the worker node has back pressure (i.e. its tasks queue is full). + * + * @param workerNodeKey - The worker node key. + * @returns `true` if the worker node has back pressure, `false` otherwise. + * @internal + */ + readonly hasWorkerNodeBackPressure: (workerNodeKey: number) => boolean /** * Emitter on which events can be listened to. * @@ -190,6 +201,7 @@ export interface IPool< * - '`destroy`': Emitted when the pool is destroyed. * - `'error'`: Emitted when an uncaught error occurs. * - `'taskError'`: Emitted when an error occurs while executing a task. + * - `'backPressure'`: Emitted when all worker nodes have back pressure (i.e. their tasks queue is full: queue size \>= pool maximum size^2). */ readonly emitter?: PoolEmitter /**