- await Utils.sleep(Constants.START_WORKER_DELAY);
- }
-}
-
-class StaticPool extends FixedThreadPool<WorkerData> {
- private static instance: StaticPool;
-
- private constructor(numberOfThreads: number, workerScript: string, opts?: PoolOptions<Worker>) {
- super(numberOfThreads, workerScript, opts);
- }
-
- public static getInstance(numberOfThreads: number, workerScript: string): StaticPool {
- if (!StaticPool.instance) {
- StaticPool.instance = new StaticPool(numberOfThreads, workerScript,
- {
- exitHandler: (code) => {
- if (code !== 0) {
- console.error(`Worker stopped with exit code ${code}`);
- }
- }
- }
- );
- }
- return StaticPool.instance;