- /**
- *
- * @param {T} elementData
- * @returns {Promise<void>}
- * @public
- */
- public async addElement(elementData: T): Promise<void> {
- await this.pool.execute(elementData);
- // Start worker sequentially to optimize memory at startup
- await Utils.sleep(this.workerStartDelay);
+ /** @inheritDoc */
+ public async start (): Promise<void> {
+ // This is intentional
+ }
+
+ /** @inheritDoc */
+ public async stop (): Promise<void> {
+ await this.pool.destroy()
+ }
+
+ /** @inheritDoc */
+ public async addElement (elementData: WorkerData): Promise<void> {
+ await this.pool.execute(elementData)
+ // Start element sequentially to optimize memory at startup
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.workerOptions.elementStartDelay! > 0 &&
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ (await sleep(randomizeDelay(this.workerOptions.elementStartDelay!)))