docs: update benchmarks vs. external pools
[poolifier.git] / src / utility-types.ts
index f330d192296dcc62a5b86a4209126d21798acff6..9ecf56577f999f4d56a5474917d522f644993749 100644 (file)
@@ -8,36 +8,44 @@ import type { IWorker, Task } from './pools/worker'
  * @typeParam Data - Type of data sent to the worker triggering an error. This can only be structured-cloneable data.
  */
 export interface TaskError<Data = unknown> {
+  /**
+   * Worker id.
+   */
+  readonly workerId: number
   /**
    * Error message.
    */
-  message: string
+  readonly message: string
   /**
    * Data passed to the worker triggering the error.
    */
-  data?: Data
+  readonly data?: Data
 }
 
 /**
  * Task performance.
+ *
+ * @internal
  */
 export interface TaskPerformance {
   /**
    * Task performance timestamp.
    */
-  timestamp: number
+  readonly timestamp: number
   /**
    * Task runtime.
    */
-  runTime?: number
+  readonly runTime?: number
   /**
    * Task event loop utilization.
    */
-  elu?: EventLoopUtilization
+  readonly elu?: EventLoopUtilization
 }
 
 /**
  * Performance statistics computation.
+ *
+ * @internal
  */
 export interface WorkerStatistics {
   runTime: boolean
@@ -53,6 +61,10 @@ export interface WorkerStatistics {
  */
 export interface MessageValue<Data = unknown, ErrorData = unknown>
   extends Task<Data> {
+  /**
+   * Worker id.
+   */
+  readonly workerId?: number
   /**
    * Kill code.
    */
@@ -66,9 +78,13 @@ export interface MessageValue<Data = unknown, ErrorData = unknown>
    */
   readonly taskPerformance?: TaskPerformance
   /**
-   * Whether to compute the given statistics or not.
+   * Whether the worker computes the given statistics or not.
    */
   readonly statistics?: WorkerStatistics
+  /**
+   * Whether the worker has started or not.
+   */
+  readonly started?: boolean
 }
 
 /**