Data = unknown,
Response = unknown
> extends FixedClusterPool<Data, Response> {
+ /**
+ * Whether the pool empty event has been emitted or not
+ */
+ private emptyEventEmitted: boolean
+
/**
* Whether the pool full event has been emitted or not.
*/
this.minimumNumberOfWorkers,
this.maximumNumberOfWorkers
)
+ this.emptyEventEmitted = false
this.fullEventEmitted = false
}
/** @inheritDoc */
protected checkAndEmitDynamicWorkerCreationEvents (): void {
- if (this.emitter != null && !this.fullEventEmitted && this.full) {
- this.emitter.emit(PoolEvents.full, this.info)
- this.fullEventEmitted = true
+ if (this.emitter != null) {
+ if (!this.fullEventEmitted && this.full) {
+ this.emitter.emit(PoolEvents.full, this.info)
+ this.fullEventEmitted = true
+ }
+ if (this.emptyEventEmitted && !this.empty) {
+ this.emptyEventEmitted = false
+ }
}
}
this.emitter.emit(PoolEvents.fullEnd, this.info)
this.fullEventEmitted = false
}
- if (this.empty) {
+ if (!this.emptyEventEmitted && this.empty) {
this.emitter.emit(PoolEvents.empty, this.info)
+ this.emptyEventEmitted = true
}
}
}
Data = unknown,
Response = unknown
> extends FixedThreadPool<Data, Response> {
+ /**
+ * Whether the pool empty event has been emitted or not
+ */
+ private emptyEventEmitted: boolean
+
/**
* Whether the pool full event has been emitted or not.
*/
this.minimumNumberOfWorkers,
this.maximumNumberOfWorkers
)
+ this.emptyEventEmitted = false
this.fullEventEmitted = false
}
/** @inheritDoc */
protected checkAndEmitDynamicWorkerCreationEvents (): void {
- if (this.emitter != null && !this.fullEventEmitted && this.full) {
- this.emitter.emit(PoolEvents.full, this.info)
- this.fullEventEmitted = true
+ if (this.emitter != null) {
+ if (!this.fullEventEmitted && this.full) {
+ this.emitter.emit(PoolEvents.full, this.info)
+ this.fullEventEmitted = true
+ }
+ if (this.emptyEventEmitted && !this.empty) {
+ this.emptyEventEmitted = false
+ }
}
}
this.emitter.emit(PoolEvents.fullEnd, this.info)
this.fullEventEmitted = false
}
- if (this.empty) {
+ if (!this.emptyEventEmitted && this.empty) {
this.emitter.emit(PoolEvents.empty, this.info)
+ this.emptyEventEmitted = true
}
}
}