}
/**
- * Worker node event callback.
+ * Worker node event detail.
*
- * @param workerId - The worker id.
* @internal
*/
-export type WorkerNodeEventCallback = (workerId: number) => void
+export interface WorkerNodeEventDetail {
+ workerId: number
+}
/**
* Worker node interface.
* @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
* @internal
*/
-export interface IWorkerNode<Worker extends IWorker, Data = unknown> {
+export interface IWorkerNode<Worker extends IWorker, Data = unknown>
+ extends EventTarget {
/**
* 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
/**
* This is the number of tasks that can be enqueued before the worker node has back pressure.
*/
tasksQueueBackPressureSize: number
- /**
- * Callback invoked when worker node tasks queue is back pressured.
- */
- onBackPressure?: WorkerNodeEventCallback
- /**
- * Callback invoked when worker node tasks queue is empty.
- */
- onEmptyQueue?: WorkerNodeEventCallback
/**
* Tasks queue size.
*
* @returns The task function worker usage statistics if the task function worker usage statistics are initialized, `undefined` otherwise.
*/
readonly getTaskFunctionWorkerUsage: (name: string) => WorkerUsage | undefined
+ /**
+ * Deletes task function worker usage statistics.
+ *
+ * @param name - The task function name.
+ * @returns `true` if the task function worker usage statistics were deleted, `false` otherwise.
+ */
+ readonly deleteTaskFunctionWorkerUsage: (name: string) => boolean
}