X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fworker.ts;h=5439606d420f0abd165b84c49157808de230aee6;hb=0743823772420af0e3ada63d8a547c7c4c22b836;hp=43e7fc608cb9be8d569ade1acc7dc72fe2194cad;hpb=b2e4d9550d6b5541749bdc42d2cbfc5371c7bf5b;p=poolifier.git diff --git a/src/pools/worker.ts b/src/pools/worker.ts index 43e7fc60..5439606d 100644 --- a/src/pools/worker.ts +++ b/src/pools/worker.ts @@ -1,14 +1,19 @@ import type { MessageChannel } from 'node:worker_threads' +import type { EventEmitter } from 'node:events' import type { CircularArray } from '../circular-array' import type { Task } from '../utility-types' /** * Callback invoked when the worker has started successfully. + * + * @typeParam Worker - Type of worker. */ export type OnlineHandler = (this: Worker) => void /** * Callback invoked if the worker has received a message. + * + * @typeParam Worker - Type of worker. */ export type MessageHandler = ( this: Worker, @@ -17,6 +22,8 @@ export type MessageHandler = ( /** * Callback invoked if the worker raised an error. + * + * @typeParam Worker - Type of worker. */ export type ErrorHandler = ( this: Worker, @@ -25,6 +32,8 @@ export type ErrorHandler = ( /** * Callback invoked when the worker exits successfully. + * + * @typeParam Worker - Type of worker. */ export type ExitHandler = ( this: Worker, @@ -96,6 +105,10 @@ export interface TaskStatistics { * Maximum number of queued tasks. */ readonly maxQueued?: number + /** + * Number of sequentially stolen tasks. + */ + sequentiallyStolen: number /** * Number of stolen tasks. */ @@ -215,6 +228,7 @@ export interface IWorker { */ export interface WorkerNodeEventDetail { workerId: number + workerNodeKey?: number } /** @@ -225,7 +239,7 @@ export interface WorkerNodeEventDetail { * @internal */ export interface IWorkerNode - extends EventTarget { + extends EventEmitter { /** * Worker. */ @@ -240,7 +254,7 @@ export interface IWorkerNode readonly usage: WorkerUsage /** * Worker choice strategy data. - * This is used to store data that is specific to the worker choice strategy. + * This is used to store data that are specific to the worker choice strategy. */ strategyData?: StrategyData /**