- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of execution response. This can only be serializable data.
+ * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
+ * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
let minNumberOfTasks = Infinity
for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
let minNumberOfTasks = Infinity
for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
const workerTasks =
workerTaskStatistics.executed +
workerTaskStatistics.executing +
workerTaskStatistics.queued
if (workerTasks === 0) {
this.nextWorkerNodeId = workerNodeKey
const workerTasks =
workerTaskStatistics.executed +
workerTaskStatistics.executing +
workerTaskStatistics.queued
if (workerTasks === 0) {
this.nextWorkerNodeId = workerNodeKey
} else if (workerTasks < minNumberOfTasks) {
minNumberOfTasks = workerTasks
this.nextWorkerNodeId = workerNodeKey
}
}
} else if (workerTasks < minNumberOfTasks) {
minNumberOfTasks = workerTasks
this.nextWorkerNodeId = workerNodeKey
}
}