+import { MessageChannel } from 'node:worker_threads'
import { CircularArray } from '../circular-array'
import { Queue } from '../queue'
import type { Task } from '../utility-types'
}
/**
- * Worker node tasks queue maximum size.
+ * Tasks queue maximum size.
*
* @returns The tasks queue maximum size.
*/
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 (!this.tasksUsage.has(name)) {
id: this.getWorkerId(worker, workerType),
type: workerType,
dynamic: false,
- ready: false
+ ready: false,
+ ...(workerType === WorkerTypes.thread && {
+ messageChannel: new MessageChannel()
+ })
}
}