- /**
- * Perform the task specified in the constructor with the data parameter.
- *
- * @param data The input for the specified task. This can only be serializable data.
- * @returns Promise that will be resolved when the task is successfully completed.
- */
+ private checkNumberOfWorkers (numberOfWorkers: number): void {
+ if (numberOfWorkers == null) {
+ throw new Error(
+ 'Cannot instantiate a pool without specifying the number of workers'
+ )
+ } else if (!Number.isSafeInteger(numberOfWorkers)) {
+ throw new Error(
+ 'Cannot instantiate a pool with a non integer number of workers'
+ )
+ } else if (numberOfWorkers < 0) {
+ throw new Error(
+ 'Cannot instantiate a pool with a negative number of workers'
+ )
+ } else if (!this.isDynamic() && numberOfWorkers === 0) {
+ throw new Error('Cannot instantiate a fixed pool with no worker')
+ }
+ }
+
+ /** @inheritdoc */
+ public isDynamic (): boolean {
+ return false
+ }
+
+ /** @inheritdoc */
+ public setWorkerChoiceStrategy (
+ workerChoiceStrategy: WorkerChoiceStrategy
+ ): void {
+ this.opts.workerChoiceStrategy = workerChoiceStrategy
+ this.workerChoiceStrategyContext.setWorkerChoiceStrategy(
+ workerChoiceStrategy
+ )
+ }
+
+ /** @inheritdoc */