repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: ensure pool event full is emitted only once
[poolifier.git]
/
src
/
pools
/
abstract-pool.ts
diff --git
a/src/pools/abstract-pool.ts
b/src/pools/abstract-pool.ts
index dceef6decb534f083510d90a947a05861c2ec2df..670866069d97dfff46e817c29f54810370dec552 100644
(file)
--- a/
src/pools/abstract-pool.ts
+++ b/
src/pools/abstract-pool.ts
@@
-122,6
+122,8
@@
export abstract class AbstractPool<
this.checkAndEmitTaskExecutionEvents.bind(this)
this.checkAndEmitTaskQueuingEvents =
this.checkAndEmitTaskQueuingEvents.bind(this)
this.checkAndEmitTaskExecutionEvents.bind(this)
this.checkAndEmitTaskQueuingEvents =
this.checkAndEmitTaskQueuingEvents.bind(this)
+ this.checkAndEmitDynamicWorkerCreationEvents =
+ this.checkAndEmitDynamicWorkerCreationEvents.bind(this)
if (this.opts.enableEvents === true) {
this.emitter = new PoolEmitter()
if (this.opts.enableEvents === true) {
this.emitter = new PoolEmitter()
@@
-749,7
+751,7
@@
export abstract class AbstractPool<
await this.destroyWorkerNode(workerNodeKey)
})
)
await this.destroyWorkerNode(workerNodeKey)
})
)
- this.emitter?.emit(PoolEvents.destroy)
+ this.emitter?.emit(PoolEvents.destroy
, this.info
)
}
protected async sendKillMessageToWorker (
}
protected async sendKillMessageToWorker (
@@
-1061,6
+1063,7
@@
export abstract class AbstractPool<
if (this.workerChoiceStrategyContext.getStrategyPolicy().useDynamicWorker) {
workerInfo.ready = true
}
if (this.workerChoiceStrategyContext.getStrategyPolicy().useDynamicWorker) {
workerInfo.ready = true
}
+ this.checkAndEmitDynamicWorkerCreationEvents()
return workerNodeKey
}
return workerNodeKey
}
@@
-1227,13
+1230,8
@@
export abstract class AbstractPool<
}
private checkAndEmitTaskExecutionEvents (): void {
}
private checkAndEmitTaskExecutionEvents (): void {
- if (this.emitter != null) {
- if (this.busy) {
- this.emitter.emit(PoolEvents.busy, this.info)
- }
- if (this.type === PoolTypes.dynamic && this.full) {
- this.emitter.emit(PoolEvents.full, this.info)
- }
+ if (this.busy) {
+ this.emitter?.emit(PoolEvents.busy, this.info)
}
}
}
}
@@
-1243,6
+1241,14
@@
export abstract class AbstractPool<
}
}
}
}
+ private checkAndEmitDynamicWorkerCreationEvents (): void {
+ if (this.type === PoolTypes.dynamic) {
+ if (this.full) {
+ this.emitter?.emit(PoolEvents.full, this.info)
+ }
+ }
+ }
+
/**
* Gets the worker information given its worker node key.
*
/**
* Gets the worker information given its worker node key.
*