refactor: cleanup type definitions
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 26 Aug 2023 23:50:54 +0000 (01:50 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 26 Aug 2023 23:50:54 +0000 (01:50 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/index.ts
src/pools/worker-node.ts
src/pools/worker.ts

index cfbffb722f119cb7a33e1f3432785e88de47019f..67f64f0b3ca91bdb853aafffa4b38fd47955a46a 100644 (file)
@@ -16,6 +16,8 @@ export type {
 } from './pools/pool'
 export { WorkerTypes } from './pools/worker'
 export type {
+  BackPressureCallback,
+  EmptyQueueCallback,
   ErrorHandler,
   EventLoopUtilizationMeasurementStatistics,
   ExitHandler,
index f3ec3be3d83f4541da3713cbd46406d19be41ac0..03fc0df192f3ce6689306ba3f6eb38c12dabed40 100644 (file)
@@ -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.
  *
index bfd73325c3204d48c656924367500b9f30efbc1d..7a8c59e7730eba9be39ae972f94022a8a65a14ce 100644 (file)
@@ -199,6 +199,9 @@ export interface IWorker {
   readonly once: (event: 'exit', handler: ExitHandler<this>) => void
 }
 
+export type EmptyQueueCallback = (workerId: number) => void
+export type BackPressureCallback = EmptyQueueCallback
+
 /**
  * Worker node interface.
  *
@@ -233,13 +236,13 @@ export interface IWorkerNode<Worker extends IWorker, Data = unknown> {
    *
    * @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.
    *