+ this.tasksUsage.clear()
+ }
+
+ /** @inheritdoc */
+ 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
+ }
+ }
+
+ /** @inheritdoc */
+ public getTaskWorkerUsage (name: string): WorkerUsage | undefined {
+ if (name === DEFAULT_TASK_NAME && !Array.isArray(this.info.taskFunctions)) {
+ throw new Error(
+ 'Cannot get task worker usage for default task function name when task function names list is not yet defined'
+ )
+ }
+ if (
+ name === DEFAULT_TASK_NAME &&
+ Array.isArray(this.info.taskFunctions) &&
+ this.info.taskFunctions.length > 1
+ ) {
+ name = this.info.taskFunctions[1]
+ }
+ if (!this.tasksUsage.has(name)) {
+ this.tasksUsage.set(name, this.initTaskWorkerUsage(name))
+ }
+ return this.tasksUsage.get(name)