From 6e9c39d3eedabc9f12808490983d36e551a75a28 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 27 Aug 2023 01:47:22 +0200 Subject: [PATCH] refactor: cleanup type definition MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/worker-node.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pools/worker-node.ts b/src/pools/worker-node.ts index 4799e11c..f3ec3be3 100644 --- a/src/pools/worker-node.ts +++ b/src/pools/worker-node.ts @@ -17,6 +17,9 @@ import { type WorkerUsage } from './worker' +type EmptyQueueCallback = (workerId: number) => void +type BackPressureCallback = EmptyQueueCallback + /** * Worker node. * @@ -36,9 +39,9 @@ implements IWorkerNode { /** @inheritdoc */ public tasksQueueBackPressureSize: number /** @inheritdoc */ - public onBackPressure?: (workerId: number) => void + public onBackPressure?: BackPressureCallback /** @inheritdoc */ - public onEmptyQueue?: (workerId: number) => void + public onEmptyQueue?: EmptyQueueCallback private readonly tasksQueue: Deque> private onEmptyQueueCount: number private readonly taskFunctionsUsage: Map @@ -185,7 +188,7 @@ implements IWorkerNode { this.onEmptyQueueCount = 0 return } - (this.onEmptyQueue as (workerId: number) => void)(this.info.id as number) + (this.onEmptyQueue as EmptyQueueCallback)(this.info.id as number) ++this.onEmptyQueueCount await sleep(exponentialDelay(this.onEmptyQueueCount)) await this.startOnEmptyQueue() -- 2.34.1