import cluster from 'node:cluster'
import { SHARE_ENV, Worker, type WorkerOptions } from 'node:worker_threads'
import { env } from 'node:process'
-import { average, isPlainObject, max, median, min } from '../utils'
-import type { MessageValue, Task } from '../utility-types'
+import { average, isPlainObject, max, median, min } from '../utils.js'
+import type { MessageValue, Task } from '../utility-types.js'
import {
type MeasurementStatisticsRequirements,
WorkerChoiceStrategies,
type WorkerChoiceStrategy
-} from './selection-strategies/selection-strategies-types'
-import type { TasksQueueOptions } from './pool'
+} from './selection-strategies/selection-strategies-types.js'
+import type { TasksQueueOptions } from './pool.js'
import {
type IWorker,
type IWorkerNode,
type WorkerType,
WorkerTypes,
type WorkerUsage
-} from './worker'
-import type { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context'
+} from './worker.js'
+import type { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context.js'
+
+export const getDefaultTasksQueueOptions = (
+ poolMaxSize: number
+): Required<TasksQueueOptions> => {
+ return {
+ size: Math.pow(poolMaxSize, 2),
+ concurrency: 1,
+ taskStealing: true,
+ tasksStealingOnBackPressure: true,
+ tasksFinishedTimeout: 2000
+ }
+}
export const checkFilePath = (filePath: string): void => {
if (filePath == null) {
* @param measurementStatistics - The measurement statistics to update.
* @param measurementRequirements - The measurement statistics requirements.
* @param measurementValue - The measurement value.
- * @param numberOfMeasurements - The number of measurements.
* @internal
*/
const updateMeasurementStatistics = (
>(
workerNode: IWorkerNode<Worker, Data>,
workerNodeEvent: string,
- numberOfEventsToWait: number
+ numberOfEventsToWait: number,
+ timeout: number
): Promise<number> => {
return await new Promise<number>(resolve => {
let events = 0
resolve(events)
}
})
+ if (timeout >= 0) {
+ setTimeout(() => {
+ resolve(events)
+ }, timeout)
+ }
})
}