X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fabstract-worker.ts;h=e2b16e25495eafb6a70a8e50ac2fa0e208583d0e;hb=9ef8fa7151c480590cce9cf98070c313717ad7b4;hp=ae95dcf825c40640b019cbc8027123ae9b2257b0;hpb=9b5c72ff77584e1e2610710b66261eb31dabb954;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index ae95dcf8..e2b16e25 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -76,6 +76,7 @@ export abstract class AbstractWorker< * Handler id of the `activeInterval` worker activity check. */ protected activeInterval?: NodeJS.Timeout + /** * Constructs a new poolifier worker. * @@ -481,7 +482,7 @@ export abstract class AbstractWorker< * * @param task - The task to execute. */ - protected run (task: Task): void { + protected readonly run = (task: Task): void => { const { name, taskId, data } = task const taskFunctionName = name ?? DEFAULT_TASK_NAME if (!this.taskFunctions.has(taskFunctionName)) { @@ -509,10 +510,10 @@ export abstract class AbstractWorker< * @param fn - Task function that will be executed. * @param task - Input data for the task function. */ - protected runSync ( + protected readonly runSync = ( fn: TaskSyncFunction, task: Task - ): void { + ): void => { const { name, taskId, data } = task try { let taskPerformance = this.beginTaskPerformance(name) @@ -543,10 +544,10 @@ export abstract class AbstractWorker< * @param fn - Task function that will be executed. * @param task - Input data for the task function. */ - protected runAsync ( + protected readonly runAsync = ( fn: TaskAsyncFunction, task: Task - ): void { + ): void => { const { name, taskId, data } = task let taskPerformance = this.beginTaskPerformance(name) fn(data)