From: Jérôme Benoit Date: Sat, 26 Aug 2023 23:47:22 +0000 (+0200) Subject: refactor: cleanup type definition X-Git-Tag: v2.6.37~39 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;ds=sidebyside;h=6e9c39d3eedabc9f12808490983d36e551a75a28;p=poolifier.git refactor: cleanup type definition Signed-off-by: Jérôme Benoit --- 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()