}
/**
- * Shut down given worker.
+ * Shutdowns given worker.
*
* @param worker A worker within `workers`.
*/
}
/**
- * Choose a worker for the next task.
+ * Chooses a worker for the next task.
*
* The default implementation uses a round robin algorithm to distribute the load.
*
}
/**
- * Send a message to the given worker.
+ * Sends a message to the given worker.
*
* @param worker The worker which should receive the message.
* @param message The message.
.requiredStatistics.runTime === true
) {
const tasksUsage = this.workersTasksUsage.get(worker)
- if (tasksUsage !== undefined && tasksUsage.run !== 0) {
+ if (tasksUsage !== undefined) {
tasksUsage.runTime += taskRunTime ?? 0
- tasksUsage.avgRunTime = tasksUsage.runTime / tasksUsage.run
+ if (tasksUsage.run !== 0) {
+ tasksUsage.avgRunTime = tasksUsage.runTime / tasksUsage.run
+ }
this.workersTasksUsage.set(worker, tasksUsage)
} else {
throw new Error(WORKER_NOT_FOUND_TASKS_USAGE_MAP)
*/
execute(data: Data): Promise<Response>
/**
- * Shut down every current worker in this pool.
+ * Shutdowns every current worker in this pool.
*/
destroy(): Promise<void>
/**