From: Jérôme Benoit Date: Fri, 25 Aug 2023 16:28:06 +0000 (+0200) Subject: refactor: remove unneeded condition in task stealing code X-Git-Tag: v2.6.35~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=60b7a7ccc07f5ae4931d35ffee48f81b1ddabb7e;p=poolifier.git refactor: remove unneeded condition in task stealing code Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/worker-node.ts b/src/pools/worker-node.ts index e28372ef..9ecfd012 100644 --- a/src/pools/worker-node.ts +++ b/src/pools/worker-node.ts @@ -178,16 +178,14 @@ implements IWorkerNode { } private async startOnEmptyQueue (): Promise { - if (this.onEmptyQueue != null) { - if (this.tasksQueue.size > 0) { - this.onEmptyQueueCount = 0 - return - } - this.onEmptyQueue(this.info.id as number) - ++this.onEmptyQueueCount - await sleep(exponentialDelay(this.onEmptyQueueCount)) - await this.startOnEmptyQueue() + if (this.tasksQueue.size > 0) { + this.onEmptyQueueCount = 0 + return } + (this.onEmptyQueue as (workerId: number) => void)(this.info.id as number) + ++this.onEmptyQueueCount + await sleep(exponentialDelay(this.onEmptyQueueCount)) + await this.startOnEmptyQueue() } private initWorkerInfo (worker: Worker, workerType: WorkerType): WorkerInfo {