X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerFactory.ts;h=fcfe4f80677820266f8438aab242907d281de1ff;hb=ded13d9799aa6fb958da48a6b702d4193e7954f2;hp=d71e4227841d5072778c2a7a8a71d256e12ae1e3;hpb=8434025b7338b3439180ed7c2bed888fc42e04d3;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index d71e4227..fcfe4f80 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -5,9 +5,13 @@ import WorkerDynamicPool from './WorkerDynamicPool'; import WorkerSet from './WorkerSet'; import WorkerStaticPool from './WorkerStaticPool'; import Wrk from './Wrk'; +import { isMainThread } from 'worker_threads'; export default class WorkerFactory { public static getWorkerImpl(workerScript: string, workerProcessType: WorkerProcessType, options?: WorkerOptions): Wrk { + if (!isMainThread) { + throw new Error('Trying to get a worker implementation outside the main thread'); + } if (Utils.isUndefined(options)) { options = {} as WorkerOptions; }