X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fworker.ts;h=4c877bc8b1dcc58871a55cd70c87871d918c4596;hb=refs%2Ftags%2Fv2.7.4;hp=be134f05f539b87bf254bbfb71e68c90e360946c;hpb=a9780ad2992ef19ef824da2d796433fc7f193ec8;p=poolifier.git diff --git a/src/pools/worker.ts b/src/pools/worker.ts index be134f05..4c877bc8 100644 --- a/src/pools/worker.ts +++ b/src/pools/worker.ts @@ -132,7 +132,7 @@ export interface WorkerInfo { /** * Worker type. */ - type: WorkerType + readonly type: WorkerType /** * Dynamic flag. */ @@ -144,7 +144,7 @@ export interface WorkerInfo { /** * Task function names. */ - taskFunctions?: string[] + taskFunctionNames?: string[] } /** @@ -171,6 +171,15 @@ export interface WorkerUsage { readonly elu: EventLoopUtilizationMeasurementStatistics } +/** + * Worker choice strategy data. + * + * @internal + */ +export interface StrategyData { + virtualTaskEndTimestamp?: number +} + /** * Worker interface. */ @@ -199,6 +208,12 @@ export interface IWorker { readonly once: (event: 'exit', handler: ExitHandler) => void } +/** + * Worker node event callback. + * + * @param workerId - The worker id. + * @internal + */ export type WorkerNodeEventCallback = (workerId: number) => void /** @@ -220,7 +235,12 @@ export interface IWorkerNode { /** * Worker usage statistics. */ - usage: WorkerUsage + readonly usage: WorkerUsage + /** + * Worker choice strategy data. + * This is used to store data that is specific to the worker choice strategy. + */ + strategyData?: StrategyData /** * Message channel (worker_threads only). */ @@ -232,14 +252,10 @@ export interface IWorkerNode { tasksQueueBackPressureSize: number /** * Callback invoked when worker node tasks queue is back pressured. - * - * @param workerId - The worker id. */ onBackPressure?: WorkerNodeEventCallback /** * Callback invoked when worker node tasks queue is empty. - * - * @param workerId - The worker id. */ onEmptyQueue?: WorkerNodeEventCallback /** @@ -299,4 +315,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 }