"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.1.1",
"prettierx": "^0.18.3",
- "rollup": "^3.0.0",
+ "rollup": "^3.1.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-command": "^1.1.3",
"rollup-plugin-delete": "^2.0.0",
}
},
"node_modules/rollup": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.0.0.tgz",
- "integrity": "sha512-iVomS2lySi4BM2QJb7lGZBjSndUEs6Ip+VDl25jcbM99VI5vWeEitvUSiNQkQkwqEiI4515m5shjyuwPcXS5Dg==",
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.1.0.tgz",
+ "integrity": "sha512-GEvr+COcXicr4nuih6mpt2Eydq5lZ72z0RrKx1H4/Q2ouT34OHrIIJ9OUj2sZqUhq7QL8Hp8Q8BoWbjL/6ccRQ==",
"dev": true,
"bin": {
"rollup": "dist/bin/rollup"
}
},
"rollup": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.0.0.tgz",
- "integrity": "sha512-iVomS2lySi4BM2QJb7lGZBjSndUEs6Ip+VDl25jcbM99VI5vWeEitvUSiNQkQkwqEiI4515m5shjyuwPcXS5Dg==",
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.1.0.tgz",
+ "integrity": "sha512-GEvr+COcXicr4nuih6mpt2Eydq5lZ72z0RrKx1H4/Q2ouT34OHrIIJ9OUj2sZqUhq7QL8Hp8Q8BoWbjL/6ccRQ==",
"dev": true,
"requires": {
"fsevents": "~2.3.2"
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.1.1",
"prettierx": "^0.18.3",
- "rollup": "^3.0.0",
+ "rollup": "^3.1.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-command": "^1.1.3",
"rollup-plugin-delete": "^2.0.0",
return freeWorker
}
- if (this.pool.busy) {
+ if (this.pool.busy === true) {
return this.workerChoiceStrategy.choose()
}
await pool.destroy()
})
+ it('Verify FAIR_SHARE strategy statistics are resets after setting it', async () => {
+ const pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js'
+ )
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ .workerLastVirtualTaskTimestamp
+ ).toBeUndefined()
+ pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
+ for (const worker of pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.keys()) {
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
+ worker
+ ).start
+ ).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
+ worker
+ ).end
+ ).toBe(0)
+ }
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
it('Verify WEIGHTED_ROUND_ROBIN strategy is taken at pool creation', async () => {
const pool = new FixedThreadPool(
max,
await pool.destroy()
})
+ it('Verify WEIGHTED_ROUND_ROBIN strategy statistics are resets after setting it', async () => {
+ const pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js'
+ )
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime
+ ).toBeUndefined()
+ pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ for (const worker of pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.keys()) {
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.get(
+ worker
+ ).runTime
+ ).toBe(0)
+ }
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
it('Verify unknown strategies throw error', () => {
expect(
() =>