X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fworker.ts;h=03cecce849a2cb9d71ad04a566795d3588238509;hb=d91689fda0fa7a85014ac25276cf2cf0a9d81ce2;hp=37d6308507669dd1f0ebcc295b790a1857c16a3e;hpb=a4846bb2399905e5529826605c20526c3bdd4333;p=poolifier.git diff --git a/src/pools/worker.ts b/src/pools/worker.ts index 37d63085..03cecce8 100644 --- a/src/pools/worker.ts +++ b/src/pools/worker.ts @@ -209,12 +209,13 @@ export interface IWorker { } /** - * 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. @@ -223,7 +224,8 @@ export type WorkerNodeEventCallback = (workerId: number) => void * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data. * @internal */ -export interface IWorkerNode { +export interface IWorkerNode + extends EventTarget { /** * Worker. */ @@ -238,7 +240,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 /** @@ -250,14 +252,6 @@ export interface IWorkerNode { * 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. * @@ -315,4 +309,11 @@ export interface IWorkerNode { * @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 }