- /**
- *
- * @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 start (): void {
+ this.pool.start()
+ }
+
+ /** @inheritDoc */
+ public async stop (): Promise<void> {
+ await this.pool.destroy()
+ }
+
+ /** @inheritDoc */
+ public async addElement (elementData: D): Promise<R> {
+ const response = 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.elementAddDelay! > 0 &&
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ (await sleep(randomizeDelay(this.workerOptions.elementAddDelay!)))
+ return response