Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
* Whether the pool is destroying or not.
*/
private destroying: boolean
* Whether the pool is destroying or not.
*/
private destroying: boolean
+ /**
+ * Whether the minimum number of workers is starting or not.
+ */
+ private startingMinimumNumberOfWorkers: boolean
/**
* Whether the pool ready event has been emitted or not.
*/
/**
* Whether the pool ready event has been emitted or not.
*/
this.starting = false
this.destroying = false
this.readyEventEmitted = false
this.starting = false
this.destroying = false
this.readyEventEmitted = false
+ this.startingMinimumNumberOfWorkers = false
if (this.opts.startWorkers === true) {
this.start()
}
if (this.opts.startWorkers === true) {
this.start()
}
* Starts the minimum number of workers.
*/
private startMinimumNumberOfWorkers (): void {
* Starts the minimum number of workers.
*/
private startMinimumNumberOfWorkers (): void {
+ this.startingMinimumNumberOfWorkers = true
while (
this.workerNodes.reduce(
(accumulator, workerNode) =>
while (
this.workerNodes.reduce(
(accumulator, workerNode) =>
) {
this.createAndSetupWorkerNode()
}
) {
this.createAndSetupWorkerNode()
}
+ this.startingMinimumNumberOfWorkers = false
) {
if (workerNode.info.dynamic) {
this.createAndSetupDynamicWorkerNode()
) {
if (workerNode.info.dynamic) {
this.createAndSetupDynamicWorkerNode()
+ } else if (!this.startingMinimumNumberOfWorkers) {
this.startMinimumNumberOfWorkers()
}
}
this.startMinimumNumberOfWorkers()
}
}
)
workerNode.registerOnceWorkerEventHandler('exit', () => {
this.removeWorkerNode(workerNode)
)
workerNode.registerOnceWorkerEventHandler('exit', () => {
this.removeWorkerNode(workerNode)
- if (this.started && !this.destroying) {
+ if (
+ this.started &&
+ !this.startingMinimumNumberOfWorkers &&
+ !this.destroying
+ ) {
this.startMinimumNumberOfWorkers()
}
})
this.startMinimumNumberOfWorkers()
}
})