fix: update worker choice internals without tasks queuing
[poolifier.git] / src / pools / worker.ts
index 4d935a113336921a5f49e6858046b07a863096fd..598e6be82ca22588c34f04d6a0c402359956b66d 100644 (file)
@@ -1,4 +1,3 @@
-import type { EventLoopUtilization } from 'node:perf_hooks'
 import type { CircularArray } from '../circular-array'
 import type { Queue } from '../queue'
 
@@ -57,50 +56,60 @@ export interface Task<Data = unknown> {
 }
 
 /**
- * Measure statistics.
+ * Measurement statistics.
  *
  * @internal
  */
-export interface MeasureStatistics {
+export interface MeasurementStatistics {
   /**
-   * Measure aggregation.
+   * Measurement aggregate.
    */
-  aggregation: number
+  aggregate: number
   /**
-   * Measure average.
+   * Measurement average.
    */
   average: number
   /**
-   * Measure median.
+   * Measurement median.
    */
   median: number
   /**
-   * Measure history.
+   * Measurement history.
    */
   history: CircularArray<number>
 }
 
 /**
- * Task statistics.
+ * Event loop utilization measurement statistics.
  *
  * @internal
  */
+export interface EventLoopUtilizationMeasurementStatistics {
+  idle: MeasurementStatistics
+  active: MeasurementStatistics
+  utilization: number
+}
 
+/**
+ * Task statistics.
+ *
+ * @internal
+ */
 export interface TaskStatistics {
   /**
-   * Number of tasks executed.
+   * Number of executed tasks.
    */
   executed: number
   /**
-   * Number of tasks executing.
+   * Number of executing tasks.
    */
   executing: number
   /**
-   * Number of tasks queued.
+   * Number of queued tasks.
    */
-  queued: number
+  readonly queued: number
   /**
-   * Number of tasks failed.
+   * Number of failed tasks.
    */
   failed: number
 }
@@ -118,15 +127,15 @@ export interface WorkerUsage {
   /**
    * Tasks runtime statistics.
    */
-  runTime: MeasureStatistics
+  runTime: MeasurementStatistics
   /**
    * Tasks wait time statistics.
    */
-  waitTime: MeasureStatistics
+  waitTime: MeasurementStatistics
   /**
-   * Event loop utilization.
+   * Tasks event loop utilization statistics.
    */
-  elu: EventLoopUtilization | undefined
+  elu: EventLoopUtilizationMeasurementStatistics
 }
 
 /**