- public closeChannel (): void {
- if (this.info.messageChannel != null) {
- this.info.messageChannel?.port1.unref()
- this.info.messageChannel?.port2.unref()
- this.info.messageChannel?.port1.close()
- this.info.messageChannel?.port2.close()
- delete this.info.messageChannel
+ public registerWorkerEventHandler (
+ event: string,
+ handler: EventHandler<Worker>
+ ): void {
+ this.worker.on(event, handler)
+ }
+
+ /** @inheritdoc */
+ public registerOnceWorkerEventHandler (
+ event: string,
+ handler: EventHandler<Worker>
+ ): void {
+ this.worker.once(event, handler)
+ }
+
+ /** @inheritdoc */
+ public getTaskFunctionWorkerUsage (name: string): WorkerUsage | undefined {
+ if (!Array.isArray(this.info.taskFunctionNames)) {
+ throw new Error(
+ `Cannot get task function worker usage for task function name '${name}' when task function names list is not yet defined`
+ )
+ }
+ if (
+ Array.isArray(this.info.taskFunctionNames) &&
+ this.info.taskFunctionNames.length < 3
+ ) {
+ throw new Error(
+ `Cannot get task function worker usage for task function name '${name}' when task function names list has less than 3 elements`
+ )