FixedThreadPool,
WorkerChoiceStrategies
} = require('../../../lib/index')
-const numberOfWorkers = 1
-const workerNotFoundInTasksUsageMapError = new Error(
- 'Worker could not be found in worker tasks usage map'
-)
-class StubPoolWithWorkerTasksUsageMapClear extends FixedThreadPool {
- removeAllWorker () {
- this.workersTasksUsage.clear()
+
+describe('Abstract pool test suite', () => {
+ const numberOfWorkers = 1
+ const workerNotFoundInTasksUsageMapError = new Error(
+ 'Worker could not be found in worker tasks usage map'
+ )
+ class StubPoolWithWorkerTasksUsageMapClear extends FixedThreadPool {
+ removeAllWorker () {
+ this.workersTasksUsage.clear()
+ }
}
-}
-class StubPoolWithIsMainMethod extends FixedThreadPool {
- isMain () {
- return false
+ class StubPoolWithIsMainMethod extends FixedThreadPool {
+ isMain () {
+ return false
+ }
}
-}
-describe('Abstract pool test suite', () => {
it('Simulate pool creation from a non main thread/process', () => {
expect(
() =>
)
const promises = []
for (let i = 0; i < numberOfWorkers * 2; i++) {
- promises.push(pool.execute({ test: 'test' }))
+ promises.push(pool.execute())
}
for (const tasksUsage of pool.workersTasksUsage.values()) {
expect(tasksUsage).toBeDefined()
let poolBusy = 0
pool.emitter.on('busy', () => poolBusy++)
for (let i = 0; i < numberOfWorkers * 2; i++) {
- promises.push(pool.execute({ test: 'test' }))
+ promises.push(pool.execute())
}
await Promise.all(promises)
// The `busy` event is triggered when the number of submitted tasks at once reach the number of fixed pool workers.