+import type { MessageChannel } from 'node:worker_threads'
import type { CircularArray } from '../circular-array'
+import type { Task } from '../utility-types'
/**
* Callback invoked if the worker has received a message.
exitCode: number
) => void
-/**
- * Message object that is passed as a task between main worker and worker.
- *
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
- * @internal
- */
-export interface Task<Data = unknown> {
- /**
- * Worker id.
- */
- readonly workerId: number
- /**
- * Task name.
- */
- readonly name?: string
- /**
- * Task input data that will be passed to the worker.
- */
- readonly data?: Data
- /**
- * Timestamp.
- */
- readonly timestamp?: number
- /**
- * Message UUID.
- */
- readonly id?: string
-}
-
/**
* Measurement statistics.
*
* Ready flag.
*/
ready: boolean
+ /**
+ * Message channel.
+ */
+ messageChannel?: MessageChannel
}
/**
*/
readonly resetUsage: () => void
/**
- * Gets task usage statistics.
+ * Close communication channel.
+ */
+ readonly closeChannel: () => void
+ /**
+ * Gets task worker usage statistics.
*/
readonly getTaskWorkerUsage: (name: string) => WorkerUsage | undefined
}