repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): bump typescript
[poolifier.git]
/
src
/
pools
/
abstract-pool.ts
diff --git
a/src/pools/abstract-pool.ts
b/src/pools/abstract-pool.ts
index 0cec96ab5ac277dcb41336a89f3776806c956cc8..b5e528ec643bb7d58325ab46d49f82c64f0f442b 100644
(file)
--- a/
src/pools/abstract-pool.ts
+++ b/
src/pools/abstract-pool.ts
@@
-117,6
+117,10
@@
export abstract class AbstractPool<
* 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.
*/
@@
-175,6
+179,7
@@
export abstract class AbstractPool<
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()
}
@@
-953,6
+958,7
@@
export abstract class AbstractPool<
* 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) =>
@@
-962,6
+968,7
@@
export abstract class AbstractPool<
) {
this.createAndSetupWorkerNode()
}
) {
this.createAndSetupWorkerNode()
}
+ this.startingMinimumNumberOfWorkers = false
}
/** @inheritdoc */
}
/** @inheritdoc */
@@
-1063,7
+1070,9
@@
export abstract class AbstractPool<
}
/**
}
/**
- * Should return whether the worker is the main worker or not.
+ * Returns whether the worker is the main worker or not.
+ *
+ * @returns `true` if the worker is the main worker, `false` otherwise.
*/
protected abstract isMain (): boolean
*/
protected abstract isMain (): boolean
@@
-1251,8
+1260,8
@@
export abstract class AbstractPool<
) {
if (workerNode.info.dynamic) {
this.createAndSetupDynamicWorkerNode()
) {
if (workerNode.info.dynamic) {
this.createAndSetupDynamicWorkerNode()
- } else {
- this.
createAndSetupWorkerNode
()
+ } else
if (!this.startingMinimumNumberOfWorkers)
{
+ this.
startMinimumNumberOfWorkers
()
}
}
if (
}
}
if (
@@
-1273,7
+1282,11
@@
export abstract class AbstractPool<
)
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()
}
})