+ /** @inheritDoc */
+ public async start(): Promise<void> {
+ this.addWorkerSetElement();
+ // Add worker set element sequentially to optimize memory at startup
+ this.workerOptions.workerStartDelay > 0 && (await sleep(this.workerOptions.workerStartDelay));
+ }
+
+ /** @inheritDoc */
+ public async stop(): Promise<void> {
+ for (const workerSetElement of this.workerSet) {
+ await workerSetElement.worker.terminate();
+ }
+ this.workerSet.clear();
+ }
+