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<Worker extends IWorker> = (this: Worker) => void
/**
* Callback invoked if the worker has received a message.
+ *
+ * @typeParam Worker - Type of worker.
*/
export type MessageHandler<Worker extends IWorker> = (
this: Worker,
/**
* Callback invoked if the worker raised an error.
+ *
+ * @typeParam Worker - Type of worker.
*/
export type ErrorHandler<Worker extends IWorker> = (
this: Worker,
/**
* Callback invoked when the worker exits successfully.
+ *
+ * @typeParam Worker - Type of worker.
*/
export type ExitHandler<Worker extends IWorker> = (
this: Worker,
* Maximum number of queued tasks.
*/
readonly maxQueued?: number
+ /**
+ * Number of sequentially stolen tasks.
+ */
+ sequentiallyStolen: number
/**
* Number of stolen tasks.
*/
*/
export interface WorkerNodeEventDetail {
workerId: number
+ workerNodeKey?: number
}
/**
* @internal
*/
export interface IWorkerNode<Worker extends IWorker, Data = unknown>
- extends EventTarget {
+ extends EventEmitter {
/**
* Worker.
*/
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
/**