*/
class DynamicThreadPool extends FixedThreadPool {
/**
- *
- * @param {Number} min Min number of threads that will be always active
- * @param {Number} max Max number of threads that will be active
- */
+ *
+ * @param {Number} min Min number of threads that will be always active
+ * @param {Number} max Max number of threads that will be active
+ */
constructor (min, max, filename, opts) {
super(min, filename, opts)
this.max = max
}
// all workers are busy create a new worker
const worker = this._newWorker()
- worker.port2.on('message', (message) => {
+ worker.port2.on('message', message => {
if (message.kill) {
worker.postMessage({ kill: 1 })
worker.terminate()
// clean workers from data structures
- const myIndex = this.workers.indexOf(worker)
- this.workers.splice(myIndex, 1)
+ const workerIndex = this.workers.indexOf(worker)
+ this.workers.splice(workerIndex, 1)
this.tasks.delete(worker)
}
})