From: Jérôme Benoit Date: Sat, 26 Aug 2023 23:50:54 +0000 (+0200) Subject: refactor: cleanup type definitions X-Git-Tag: v2.6.37~38 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ec287edfc71369699efd04e284db8759ace8a59c;p=poolifier.git refactor: cleanup type definitions Signed-off-by: Jérôme Benoit --- diff --git a/src/index.ts b/src/index.ts index cfbffb72..67f64f0b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,8 @@ export type { } from './pools/pool' export { WorkerTypes } from './pools/worker' export type { + BackPressureCallback, + EmptyQueueCallback, ErrorHandler, EventLoopUtilizationMeasurementStatistics, ExitHandler, diff --git a/src/pools/worker-node.ts b/src/pools/worker-node.ts index f3ec3be3..03fc0df1 100644 --- a/src/pools/worker-node.ts +++ b/src/pools/worker-node.ts @@ -9,6 +9,8 @@ import { } from '../utils' import { Deque } from '../deque' import { + type BackPressureCallback, + type EmptyQueueCallback, type IWorker, type IWorkerNode, type WorkerInfo, @@ -17,9 +19,6 @@ import { type WorkerUsage } from './worker' -type EmptyQueueCallback = (workerId: number) => void -type BackPressureCallback = EmptyQueueCallback - /** * Worker node. * diff --git a/src/pools/worker.ts b/src/pools/worker.ts index bfd73325..7a8c59e7 100644 --- a/src/pools/worker.ts +++ b/src/pools/worker.ts @@ -199,6 +199,9 @@ export interface IWorker { readonly once: (event: 'exit', handler: ExitHandler) => void } +export type EmptyQueueCallback = (workerId: number) => void +export type BackPressureCallback = EmptyQueueCallback + /** * Worker node interface. * @@ -233,13 +236,13 @@ export interface IWorkerNode { * * @param workerId - The worker id. */ - onBackPressure?: (workerId: number) => void + onBackPressure?: EmptyQueueCallback /** * Callback invoked when worker node tasks queue is empty. * * @param workerId - The worker id. */ - onEmptyQueue?: (workerId: number) => void + onEmptyQueue?: BackPressureCallback /** * Tasks queue size. *