X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futility-types.ts;h=f330d192296dcc62a5b86a4209126d21798acff6;hb=448ad5810fdecae4747d35d64b3f6e016ed264f1;hp=57ff000330e29cc7dffb3541a65438c3edf65b80;hpb=213e817d69db5ac80137ef59ed5cdadcde4d73cf;p=poolifier.git diff --git a/src/utility-types.ts b/src/utility-types.ts index 57ff0003..f330d192 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -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 = { -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 { /** @@ -39,10 +30,6 @@ export interface TaskPerformance { * Task runtime. */ runTime?: number - /** - * Task wait time. - */ - waitTime?: number /** * Task event loop utilization. */ @@ -54,23 +41,18 @@ export interface TaskPerformance { */ export interface WorkerStatistics { runTime: boolean - waitTime: boolean elu: boolean } /** * 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 { +export interface MessageValue + extends Task { /** * Kill code. */ @@ -78,15 +60,11 @@ export interface MessageValue< /** * Task error. */ - readonly taskError?: TaskError + readonly taskError?: TaskError /** * Task performance. */ readonly taskPerformance?: TaskPerformance - /** - * Reference to main worker. - */ - readonly parent?: MainWorker /** * Whether to compute the given statistics or not. */ @@ -97,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<