X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=6081902720554c2bcdb809d37f04d5f93ed89da7;hb=db746922cea3decbb34b5878d56a468d659d33f5;hp=4abbd615efe13869feaff7b9e1b19ee584b17990;hpb=68cbdc846878bc058323b757a68b4c83eedc6388;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 4abbd615..60819027 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1269,8 +1269,15 @@ export abstract class AbstractPool< } else { this.enqueueTask(destinationWorkerNodeKey, task) } - ++destinationWorkerNode.usage.tasks.stolen - if (this.shallUpdateTaskFunctionWorkerUsage(destinationWorkerNodeKey)) { + if (destinationWorkerNode?.usage != null) { + ++destinationWorkerNode.usage.tasks.stolen + } + if ( + this.shallUpdateTaskFunctionWorkerUsage(destinationWorkerNodeKey) && + destinationWorkerNode.getTaskFunctionWorkerUsage( + task.name as string + ) != null + ) { const taskFunctionWorkerUsage = destinationWorkerNode.getTaskFunctionWorkerUsage( task.name as string @@ -1312,8 +1319,13 @@ export abstract class AbstractPool< } else { this.enqueueTask(workerNodeKey, task) } - ++workerNode.usage.tasks.stolen - if (this.shallUpdateTaskFunctionWorkerUsage(workerNodeKey)) { + if (workerNode?.usage != null) { + ++workerNode.usage.tasks.stolen + } + if ( + this.shallUpdateTaskFunctionWorkerUsage(workerNodeKey) && + workerNode.getTaskFunctionWorkerUsage(task.name as string) != null + ) { const taskFunctionWorkerUsage = workerNode.getTaskFunctionWorkerUsage( task.name as string ) as WorkerUsage