chore: v3.1.8
[poolifier.git] / src / worker / abstract-worker.ts
index 15259106cfe59e1e73d7ec3a613da27a262c62a8..e2b16e25495eafb6a70a8e50ac2fa0e208583d0e 100644 (file)
@@ -76,10 +76,10 @@ export abstract class AbstractWorker<
    * Handler id of the `activeInterval` worker activity check.
    */
   protected activeInterval?: NodeJS.Timeout
+
   /**
    * Constructs a new poolifier worker.
    *
-   * @param type - The type of async event.
    * @param isMain - Whether this is the main worker or not.
    * @param mainWorker - Reference to main worker.
    * @param taskFunctions - Task function(s) processed by the worker when the pool's `execution` function is invoked. The first function is the default function.
@@ -482,7 +482,7 @@ export abstract class AbstractWorker<
    *
    * @param task - The task to execute.
    */
-  protected run (task: Task<Data>): void {
+  protected readonly run = (task: Task<Data>): void => {
     const { name, taskId, data } = task
     const taskFunctionName = name ?? DEFAULT_TASK_NAME
     if (!this.taskFunctions.has(taskFunctionName)) {
@@ -510,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<Data, Response>,
     task: Task<Data>
-  ): void {
+  ): void => {
     const { name, taskId, data } = task
     try {
       let taskPerformance = this.beginTaskPerformance(name)
@@ -544,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<Data, Response>,
     task: Task<Data>
-  ): void {
+  ): void => {
     const { name, taskId, data } = task
     let taskPerformance = this.beginTaskPerformance(name)
     fn(data)