docs: update benchmarks vs. external pools
[poolifier.git] / src / utility-types.ts
index bfbc2a84e376ac1db341614f6427943d5405285f..f330d192296dcc62a5b86a4209126d21798acff6 100644 (file)
@@ -1,20 +1,11 @@
-import type { Worker as ClusterWorker } from 'node:cluster'
-import type { MessagePort } from 'node:worker_threads'
 import type { EventLoopUtilization } from 'node:perf_hooks'
 import type { KillBehavior } from './worker/worker-options'
 import type { IWorker, Task } from './pools/worker'
 
-/**
- * Make all properties in T non-readonly.
- *
- * @typeParam T - Type in which properties will be non-readonly.
- */
-export type Draft<T> = { -readonly [P in keyof T]?: T[P] }
-
 /**
  * Task error.
  *
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
+ * @typeParam Data - Type of data sent to the worker triggering an error. This can only be structured-cloneable data.
  */
 export interface TaskError<Data = unknown> {
   /**
@@ -56,16 +47,12 @@ export interface WorkerStatistics {
 /**
  * Message object that is passed between main worker and worker.
  *
- * @typeParam MessageData - Type of data sent to and/or from the worker. This can only be serializable data.
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam MainWorker - Type of main worker.
+ * @typeParam Data - Type of data sent to the worker or execution response. This can only be structured-cloneable data.
+ * @typeParam ErrorData - Type of data sent to the worker triggering an error. This can only be structured-cloneable data.
  * @internal
  */
-export interface MessageValue<
-  MessageData = unknown,
-  Data = unknown,
-  MainWorker extends ClusterWorker | MessagePort = ClusterWorker | MessagePort
-> extends Task<MessageData> {
+export interface MessageValue<Data = unknown, ErrorData = unknown>
+  extends Task<Data> {
   /**
    * Kill code.
    */
@@ -73,15 +60,11 @@ export interface MessageValue<
   /**
    * Task error.
    */
-  readonly taskError?: TaskError<Data>
+  readonly taskError?: TaskError<ErrorData>
   /**
    * Task performance.
    */
   readonly taskPerformance?: TaskPerformance
-  /**
-   * Reference to main worker.
-   */
-  readonly parent?: MainWorker
   /**
    * Whether to compute the given statistics or not.
    */
@@ -92,7 +75,7 @@ export interface MessageValue<
  * An object holding the execution response promise resolve/reject callbacks.
  *
  * @typeParam Worker - Type of worker.
- * @typeParam Response - Type of execution response. This can only be serializable data.
+ * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
  * @internal
  */
 export interface PromiseResponseWrapper<