repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
docs: refine README.md
[poolifier.git]
/
src
/
pools
/
abstract-pool.ts
diff --git
a/src/pools/abstract-pool.ts
b/src/pools/abstract-pool.ts
index 52829c28163637f97947343b88aab983ab1a101f..4f60dff0279643a864b8c570eaddf3e3af9e7546 100644
(file)
--- a/
src/pools/abstract-pool.ts
+++ b/
src/pools/abstract-pool.ts
@@
-137,7
+137,7
@@
export abstract class AbstractPool<
/**
* The start timestamp of the pool.
*/
/**
* The start timestamp of the pool.
*/
- private
readonly startTimestamp
+ private
startTimestamp?: number
/**
* Constructs a new poolifier pool.
/**
* Constructs a new poolifier pool.
@@
-193,8
+193,6
@@
export abstract class AbstractPool<
if (this.opts.startWorkers === true) {
this.start()
}
if (this.opts.startWorkers === true) {
this.start()
}
-
- this.startTimestamp = performance.now()
}
private checkPoolType (): void {
}
private checkPoolType (): void {
@@
-487,6
+485,9
@@
export abstract class AbstractPool<
* @returns The pool utilization.
*/
private get utilization (): number {
* @returns The pool utilization.
*/
private get utilization (): number {
+ if (this.startTimestamp == null) {
+ return 0
+ }
const poolTimeCapacity =
(performance.now() - this.startTimestamp) *
(this.maximumNumberOfWorkers ?? this.minimumNumberOfWorkers)
const poolTimeCapacity =
(performance.now() - this.startTimestamp) *
(this.maximumNumberOfWorkers ?? this.minimumNumberOfWorkers)
@@
-551,7
+552,7
@@
export abstract class AbstractPool<
let requireSync = false
checkValidWorkerChoiceStrategy(workerChoiceStrategy)
if (workerChoiceStrategyOptions != null) {
let requireSync = false
checkValidWorkerChoiceStrategy(workerChoiceStrategy)
if (workerChoiceStrategyOptions != null) {
- requireSync = this.setWorkerChoiceStrategyOptions(
+ requireSync =
!
this.setWorkerChoiceStrategyOptions(
workerChoiceStrategyOptions
)
}
workerChoiceStrategyOptions
)
}
@@
-1087,6
+1088,7
@@
export abstract class AbstractPool<
}
this.starting = true
this.startMinimumNumberOfWorkers()
}
this.starting = true
this.startMinimumNumberOfWorkers()
+ this.startTimestamp = performance.now()
this.starting = false
this.started = true
}
this.starting = false
this.started = true
}
@@
-1111,6
+1113,7
@@
export abstract class AbstractPool<
this.emitter?.emit(PoolEvents.destroy, this.info)
this.emitter?.emitDestroy()
this.readyEventEmitted = false
this.emitter?.emit(PoolEvents.destroy, this.info)
this.emitter?.emitDestroy()
this.readyEventEmitted = false
+ delete this.startTimestamp
this.destroying = false
this.started = false
}
this.destroying = false
this.started = false
}
@@
-1294,7
+1297,7
@@
export abstract class AbstractPool<
}
/**
}
/**
- * Chooses a worker node for the next task.
+ * Chooses a worker node for the next task
given the worker choice strategy
.
*
* @param workerChoiceStrategy - The worker choice strategy.
* @returns The chosen worker node key
*
* @param workerChoiceStrategy - The worker choice strategy.
* @returns The chosen worker node key