X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fworker-node.ts;h=ca275dedab806b9a4cc2c9c6aee5d3cf550b99f5;hb=946b809b91118cd7442b90971344e53e15c26466;hp=f9b4016c29b078143d6f56d9acfcaf24b06e688d;hpb=a9780ad2992ef19ef824da2d796433fc7f193ec8;p=poolifier.git diff --git a/src/pools/worker-node.ts b/src/pools/worker-node.ts index f9b4016c..ca275ded 100644 --- a/src/pools/worker-node.ts +++ b/src/pools/worker-node.ts @@ -13,6 +13,7 @@ import { Deque } from '../deque' import { type IWorker, type IWorkerNode, + type StrategyData, type WorkerInfo, type WorkerNodeEventCallback, type WorkerType, @@ -35,6 +36,8 @@ implements IWorkerNode { /** @inheritdoc */ public usage: WorkerUsage /** @inheritdoc */ + public strategyData?: StrategyData + /** @inheritdoc */ public messageChannel?: MessageChannel /** @inheritdoc */ public tasksQueueBackPressureSize: number @@ -53,19 +56,7 @@ implements IWorkerNode { * @param tasksQueueBackPressureSize - The tasks queue back pressure size. */ constructor (worker: Worker, tasksQueueBackPressureSize: number) { - if (worker == null) { - throw new TypeError('Cannot construct a worker node without a worker') - } - if (tasksQueueBackPressureSize == null) { - throw new TypeError( - 'Cannot construct a worker node without a tasks queue back pressure size' - ) - } - if (!Number.isSafeInteger(tasksQueueBackPressureSize)) { - throw new TypeError( - 'Cannot construct a worker node with a tasks queue back pressure size that is not an integer' - ) - } + this.checkWorkerNodeArguments(worker, tasksQueueBackPressureSize) this.worker = worker this.info = this.initWorkerInfo(worker) this.usage = this.initWorkerUsage() @@ -270,4 +261,28 @@ implements IWorkerNode { } } } + + private checkWorkerNodeArguments ( + worker: Worker, + tasksQueueBackPressureSize: number + ): void { + if (worker == null) { + throw new TypeError('Cannot construct a worker node without a worker') + } + if (tasksQueueBackPressureSize == null) { + throw new TypeError( + 'Cannot construct a worker node without a tasks queue back pressure size' + ) + } + if (!Number.isSafeInteger(tasksQueueBackPressureSize)) { + throw new TypeError( + 'Cannot construct a worker node with a tasks queue back pressure size that is not an integer' + ) + } + if (tasksQueueBackPressureSize <= 0) { + throw new RangeError( + 'Cannot construct a worker node with a tasks queue back pressure size that is not a positive integer' + ) + } + } }