return this.workerNodes.length <= 1 || this.info.queuedTasks === 0
}
- private checkAndEmitEmptyEvent (): void {
- if (this.emitter != null && this.empty) {
- this.emitter.emit(PoolEvents.empty, this.info)
- }
- }
-
private checkAndEmitReadyEvent (): void {
if (this.emitter != null && !this.readyEventEmitted && this.ready) {
this.emitter.emit(PoolEvents.ready, this.info)
this.workerChoiceStrategiesContext?.remove(workerNodeKey)
workerNode.info.dynamic &&
this.checkAndEmitDynamicWorkerDestructionEvents()
- this.checkAndEmitEmptyEvent()
}
}
/** @inheritDoc */
protected checkAndEmitDynamicWorkerDestructionEvents (): void {
- if (this.emitter != null && this.fullEventEmitted && !this.full) {
- this.emitter.emit(PoolEvents.fullEnd, this.info)
- this.fullEventEmitted = false
+ if (this.emitter != null) {
+ if (this.fullEventEmitted && !this.full) {
+ this.emitter.emit(PoolEvents.fullEnd, this.info)
+ this.fullEventEmitted = false
+ }
+ if (this.empty) {
+ this.emitter.emit(PoolEvents.empty, this.info)
+ }
}
}
/** @inheritDoc */
protected checkAndEmitDynamicWorkerDestructionEvents (): void {
- if (this.emitter != null && this.fullEventEmitted && !this.full) {
- this.emitter.emit(PoolEvents.fullEnd, this.info)
- this.fullEventEmitted = false
+ if (this.emitter != null) {
+ if (this.fullEventEmitted && !this.full) {
+ this.emitter.emit(PoolEvents.fullEnd, this.info)
+ this.fullEventEmitted = false
+ }
+ if (this.empty) {
+ this.emitter.emit(PoolEvents.empty, this.info)
+ }
}
}