X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=f7e6f8d2c17b1e1ef0773f7273541c42bad55dde;hb=cd312fe991ae10e66137fe4f70525076bbe4a04d;hp=70459dbbee743d82f158eb9739e9bda8367478e4;hpb=76a3a76becd6ac41efb3271c708431a666828c30;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 70459dbb..f7e6f8d2 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -70,7 +70,7 @@ export abstract class AbstractPool< public readonly workerNodes: Array> = [] /** @inheritDoc */ - public readonly emitter?: PoolEmitter + public emitter?: PoolEmitter /** * The task execution response promise map: @@ -142,7 +142,7 @@ export abstract class AbstractPool< this.enqueueTask = this.enqueueTask.bind(this) if (this.opts.enableEvents === true) { - this.emitter = new PoolEmitter() + this.initializeEventEmitter() } this.workerChoiceStrategyContext = new WorkerChoiceStrategyContext< Worker, @@ -261,6 +261,12 @@ export abstract class AbstractPool< } } + private initializeEventEmitter (): void { + this.emitter = new PoolEmitter({ + name: `poolifier:${this.type}-${this.worker}-pool` + }) + } + /** @inheritDoc */ public get info (): PoolInfo { return { @@ -938,6 +944,7 @@ export abstract class AbstractPool< }) ) this.emitter?.emit(PoolEvents.destroy, this.info) + this.emitter?.emitDestroy() this.started = false }