X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futility-types.ts;h=e1fb311e45b4eb8ed0e5d33cda3b3806d7526f5b;hb=68f1f53125a7fd7744a6a847bc8e19c8da375892;hp=c4a8bf115174d6d60bb114975dfabc81f4a75c9f;hpb=501aea93c14789538c4e221fbab2f8afb80f4cf9;p=poolifier.git diff --git a/src/utility-types.ts b/src/utility-types.ts index c4a8bf11..e1fb311e 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -1,5 +1,5 @@ import type { EventLoopUtilization } from 'node:perf_hooks' -import type { MessagePort } from 'node:worker_threads' +import type { MessagePort, TransferListItem } from 'node:worker_threads' import type { KillBehavior } from './worker/worker-options' /** @@ -47,13 +47,19 @@ export interface TaskPerformance { } /** - * Performance statistics computation. + * Worker task performance statistics computation settings. * * @internal */ export interface WorkerStatistics { - runTime: boolean - elu: boolean + /** + * Whether the worker computes the task runtime or not. + */ + readonly runTime: boolean + /** + * Whether the worker computes the task event loop utilization (ELU) or not. + */ + readonly elu: boolean } /** @@ -75,14 +81,18 @@ export interface Task { * Task input data that will be passed to the worker. */ readonly data?: Data + /** + * Array of transferable objects. + */ + readonly transferList?: TransferListItem[] /** * Timestamp. */ readonly timestamp?: number /** - * Message UUID. + * Task UUID. */ - readonly id?: string + readonly taskId?: string } /** @@ -97,7 +107,7 @@ export interface MessageValue /** * Kill code. */ - readonly kill?: KillBehavior | true + readonly kill?: KillBehavior | true | 'success' | 'failure' /** * Task error. */ @@ -106,6 +116,10 @@ export interface MessageValue * Task performance. */ readonly taskPerformance?: TaskPerformance + /** + * Task function names. + */ + readonly taskFunctions?: string[] /** * Whether the worker computes the given statistics or not. */ @@ -125,7 +139,7 @@ export interface MessageValue } /** - * An object holding the execution response promise resolve/reject callbacks. + * An object holding the task execution response promise resolve/reject callbacks. * * @typeParam Response - Type of execution response. This can only be structured-cloneable data. * @internal @@ -140,7 +154,9 @@ export interface PromiseResponseWrapper { */ readonly reject: (reason?: unknown) => void /** - * The worker node key handling the execution. + * The worker node key executing the task. */ readonly workerNodeKey: number } + +export type Writable = { -readonly [P in keyof T]: T[P] }