}
protected checkDynamicPoolSize (min: number, max: number): void {
- if (this.type === PoolTypes.dynamic && min > max) {
- throw new RangeError(
- 'Cannot instantiate a dynamic pool with a maximum pool size inferior to the minimum pool size'
- )
- } else if (this.type === PoolTypes.dynamic && min === 0 && max === 0) {
- throw new RangeError(
- 'Cannot instantiate a dynamic pool with a minimum pool size and a maximum pool size equal to zero'
- )
- } else if (this.type === PoolTypes.dynamic && min === max) {
- throw new RangeError(
- 'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
- )
+ if (this.type === PoolTypes.dynamic) {
+ if (min > max) {
+ throw new RangeError(
+ 'Cannot instantiate a dynamic pool with a maximum pool size inferior to the minimum pool size'
+ )
+ } else if (min === 0 && max === 0) {
+ throw new RangeError(
+ 'Cannot instantiate a dynamic pool with a minimum pool size and a maximum pool size equal to zero'
+ )
+ } else if (min === max) {
+ throw new RangeError(
+ 'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
+ )
+ }
}
}
const { WorkerFunctions } = require('../../test-types')
const { waitPoolEvents, waitWorkerEvents } = require('../../test-utils')
-describe('Fixed cluster pool test suite', async () => {
+describe('Fixed cluster pool test suite', () => {
const numberOfWorkers = 6
const pool = new FixedClusterPool(
numberOfWorkers,
errorHandler: e => console.error(e)
}
)
- let poolReady = 0
- pool.emitter.on(PoolEvents.ready, () => ++poolReady)
- await waitPoolEvents(pool, PoolEvents.ready, 1)
const queuePool = new FixedClusterPool(
numberOfWorkers,
'./tests/worker-files/cluster/testWorker.js',
})
it("Verify that 'ready' event is emitted", async () => {
+ const pool1 = new FixedClusterPool(
+ numberOfWorkers,
+ './tests/worker-files/cluster/testWorker.js',
+ {
+ errorHandler: e => console.error(e)
+ }
+ )
+ let poolReady = 0
+ pool1.emitter.on(PoolEvents.ready, () => ++poolReady)
+ await waitPoolEvents(pool1, PoolEvents.ready, 1)
expect(poolReady).toBe(1)
})
const { WorkerFunctions } = require('../../test-types')
const { waitPoolEvents, waitWorkerEvents } = require('../../test-utils')
-describe('Fixed thread pool test suite', async () => {
+describe('Fixed thread pool test suite', () => {
const numberOfThreads = 6
const pool = new FixedThreadPool(
numberOfThreads,
errorHandler: e => console.error(e)
}
)
- let poolReady = 0
- pool.emitter.on(PoolEvents.ready, () => ++poolReady)
- await waitPoolEvents(pool, PoolEvents.ready, 1)
const queuePool = new FixedThreadPool(
numberOfThreads,
'./tests/worker-files/thread/testWorker.js',
})
it("Verify that 'ready' event is emitted", async () => {
+ const pool1 = new FixedThreadPool(
+ numberOfThreads,
+ './tests/worker-files/thread/testWorker.js',
+ {
+ errorHandler: e => console.error(e)
+ }
+ )
+ let poolReady = 0
+ pool1.emitter.on(PoolEvents.ready, () => ++poolReady)
+ await waitPoolEvents(pool1, PoolEvents.ready, 1)
expect(poolReady).toBe(1)
})