repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: fix dynamic pool busy semantic
[poolifier.git]
/
src
/
pools
/
abstract-pool.ts
diff --git
a/src/pools/abstract-pool.ts
b/src/pools/abstract-pool.ts
index 66b1ea1da3f3ba47d93cda9c94d2b2a19cc63ac3..1e61071c42382e1ccb9d546cb0a035ac6196afe3 100644
(file)
--- a/
src/pools/abstract-pool.ts
+++ b/
src/pools/abstract-pool.ts
@@
-73,6
+73,12
@@
export abstract class AbstractPool<
this.checkNumberOfWorkers(this.numberOfWorkers)
this.checkFilePath(this.filePath)
this.checkPoolOptions(this.opts)
this.checkNumberOfWorkers(this.numberOfWorkers)
this.checkFilePath(this.filePath)
this.checkPoolOptions(this.opts)
+
+ this.chooseWorker.bind(this)
+ this.internalExecute.bind(this)
+ this.checkAndEmitBusy.bind(this)
+ this.sendToWorker.bind(this)
+
this.setupHook()
for (let i = 1; i <= this.numberOfWorkers; i++) {
this.setupHook()
for (let i = 1; i <= this.numberOfWorkers; i++) {
@@
-137,8
+143,10
@@
export abstract class AbstractPool<
/** {@inheritDoc} */
public abstract get type (): PoolType
/** {@inheritDoc} */
public abstract get type (): PoolType
- /** {@inheritDoc} */
- public get numberOfRunningTasks (): number {
+ /**
+ * Number of tasks concurrently running.
+ */
+ private get numberOfRunningTasks (): number {
return this.promiseResponseMap.size
}
return this.promiseResponseMap.size
}
@@
-171,10
+179,13
@@
export abstract class AbstractPool<
)
}
)
}
+ /** {@inheritDoc} */
+ public abstract get full (): boolean
+
/** {@inheritDoc} */
public abstract get busy (): boolean
/** {@inheritDoc} */
public abstract get busy (): boolean
- protected internal
GetBusyStatus
(): boolean {
+ protected internal
Busy
(): boolean {
return (
this.numberOfRunningTasks >= this.numberOfWorkers &&
this.findFreeWorkerKey() === -1
return (
this.numberOfRunningTasks >= this.numberOfWorkers &&
this.findFreeWorkerKey() === -1
@@
-261,7
+272,10
@@
export abstract class AbstractPool<
}
if (this.workerChoiceStrategyContext.getRequiredStatistics().runTime) {
workerTasksUsage.runTime += message.taskRunTime ?? 0
}
if (this.workerChoiceStrategyContext.getRequiredStatistics().runTime) {
workerTasksUsage.runTime += message.taskRunTime ?? 0
- if (workerTasksUsage.run !== 0) {
+ if (
+ this.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime &&
+ workerTasksUsage.run !== 0
+ ) {
workerTasksUsage.avgRunTime =
workerTasksUsage.runTime / workerTasksUsage.run
}
workerTasksUsage.avgRunTime =
workerTasksUsage.runTime / workerTasksUsage.run
}