### Breaking Changes
+- `FullPool` event is now renamed to `busy`.
- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
_Find more details on our JSDoc._
'./yourWorker.js',
{ errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') })
-pool.emitter.on('FullPool', () => console.log('Pool is full'))
+pool.emitter.on('busy', () => console.log('Pool is full'))
// the execute method signature is the same for both implementations,
// so you can easy switch from one to another
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
},
"piscina": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/piscina/-/piscina-2.1.0.tgz",
- "integrity": "sha512-3FgX36QyZcU4prKuNKl7/lWlOF3HAv9n7JpCjw09Zbql2KkzXXQ7E5xUS+RV5wV24Rn0r6Lr8jLdtU/cNZHAnA==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/piscina/-/piscina-2.2.0.tgz",
+ "integrity": "sha512-CQb0DfyTdC9FBIMYkVV/00fXRLKDjmWKA8S0N1zDg2JGEc5z3P9qHXtoq8OkJQ+vjCfXySkVonTNMqskMFOW/w==",
"requires": {
"eventemitter-asyncresource": "^1.0.0",
"hdr-histogram-js": "^2.0.1",
"benchmark": "^2.1.4",
"microjob": "0.7.0",
"node-worker-threads-pool": "1.4.3",
- "piscina": "2.1.0",
+ "piscina": "2.2.0",
"poolifier": "2.0.0-beta.7",
"threads": "1.6.3",
"worker-threads-pool": "2.0.0",
errorHandler: e => console.error(e),
onlineHandler: () => console.log('worker is online')
})
-pool.emitter.on('FullPool', () => maxReached++)
+pool.emitter.on('busy', () => maxReached++)
const start = Date.now()
const iterations = 1000
*
* Events that can currently be listened to:
*
- * - `'FullPool'`
+ * - `'busy'`
*/
readonly emitter: PoolEmitter
}
if (this.pool.workers.length === this.pool.max) {
- this.pool.emitter.emit('FullPool')
+ this.pool.emitter.emit('busy')
return this.workerChoiceStrategy.choose()
}
it('Verify that new workers are created when required, max size is not exceeded and that after a while new workers will die', async () => {
const promises = []
- let fullPool = 0
- pool.emitter.on('FullPool', () => fullPool++)
+ let busy = 0
+ pool.emitter.on('busy', () => busy++)
for (let i = 0; i < max * 2; i++) {
promises.push(pool.execute({ test: 'test' }))
}
expect(pool.workers.length).toBeLessThanOrEqual(max)
expect(pool.workers.length).toBeGreaterThan(min)
- expect(fullPool > 1).toBeTruthy()
+ expect(busy > 1).toBeTruthy()
const numberOfExitEvents = await TestUtils.waitExits(pool, max - min)
expect(numberOfExitEvents).toBe(max - min)
})
it('Verify that new workers are created when required, max size is not exceeded and that after a while new workers will die', async () => {
const promises = []
- let fullPool = 0
- pool.emitter.on('FullPool', () => fullPool++)
+ let busy = 0
+ pool.emitter.on('busy', () => busy++)
for (let i = 0; i < max * 2; i++) {
promises.push(pool.execute({ test: 'test' }))
}
expect(pool.workers.length).toBe(max)
- expect(fullPool > 1).toBeTruthy()
+ expect(busy > 1).toBeTruthy()
const res = await TestUtils.waitExits(pool, max - min)
expect(res).toBe(max - min)
})