X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fworker%2Fabstract-worker.ts;h=475595eccf5f2e2c85b4eac8ba251f306f472c5d;hb=refs%2Ftags%2Fv2.4.3;hp=6a7a43259f11392fc764bf74e4cada6e20bc6518;hpb=5919b303c0afd78ae8d980b2661a9f23b6377425;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 6a7a4325..475595ec 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -29,10 +29,6 @@ export abstract class AbstractWorker< * Handler Id of the `aliveInterval` worker alive check. */ protected readonly aliveInterval?: NodeJS.Timeout - /** - * Options for the worker. - */ - public readonly opts: WorkerOptions /** * Constructs a new poolifier worker. * @@ -47,7 +43,7 @@ export abstract class AbstractWorker< protected readonly isMain: boolean, fn: (data: Data) => Response, protected mainWorker: MainWorker | undefined | null, - opts: WorkerOptions = { + protected readonly opts: WorkerOptions = { /** * The kill behavior option on this Worker or its default value. */ @@ -60,7 +56,6 @@ export abstract class AbstractWorker< } ) { super(type) - this.opts = opts this.checkFunctionInput(fn) this.checkWorkerOptions(this.opts) if (!this.isMain) { @@ -81,18 +76,18 @@ export abstract class AbstractWorker< value: MessageValue, fn: (data: Data) => Response ): void { - if (value.data !== undefined && value.id !== undefined) { + if (value.data != null && value.id != null) { // Here you will receive messages if (this.opts.async === true) { this.runInAsyncScope(this.runAsync.bind(this), this, fn, value) } else { this.runInAsyncScope(this.run.bind(this), this, fn, value) } - } else if (value.parent !== undefined) { + } else if (value.parent != null) { // Save a reference of the main worker to communicate with it // This will be received once this.mainWorker = value.parent - } else if (value.kill !== undefined) { + } else if (value.kill != null) { // Here is time to kill this worker, just clearing the interval this.aliveInterval != null && clearInterval(this.aliveInterval) this.emitDestroy()