WorkerTypes,
type WorkerUsage
} from './worker'
+import { checkWorkerNodeArguments } from './utils'
/**
* Worker node.
* @param tasksQueueBackPressureSize - The tasks queue back pressure size.
*/
constructor (worker: Worker, tasksQueueBackPressureSize: number) {
- this.checkWorkerNodeArguments(worker, tasksQueueBackPressureSize)
+ checkWorkerNodeArguments<Worker>(worker, tasksQueueBackPressureSize)
this.worker = worker
this.info = this.initWorkerInfo(worker)
this.usage = this.initWorkerUsage()
return this.taskFunctionsUsage.get(name)
}
+ /** @inheritdoc */
+ public deleteTaskFunctionWorkerUsage (name: string): boolean {
+ return this.taskFunctionsUsage.delete(name)
+ }
+
private async startOnEmptyQueue (): Promise<void> {
if (
this.onEmptyQueueCount > 0 &&
failed: 0
},
runTime: {
- history: new CircularArray()
+ history: new CircularArray<number>()
},
waitTime: {
- history: new CircularArray()
+ history: new CircularArray<number>()
},
elu: {
idle: {
- history: new CircularArray()
+ history: new CircularArray<number>()
},
active: {
- history: new CircularArray()
+ history: new CircularArray<number>()
}
}
}
failed: 0
},
runTime: {
- history: new CircularArray()
+ history: new CircularArray<number>()
},
waitTime: {
- history: new CircularArray()
+ history: new CircularArray<number>()
},
elu: {
idle: {
- history: new CircularArray()
+ history: new CircularArray<number>()
},
active: {
- history: new CircularArray()
+ history: new CircularArray<number>()
}
}
}
}
-
- private checkWorkerNodeArguments (
- worker: Worker,
- tasksQueueBackPressureSize: number
- ): void {
- if (worker == null) {
- throw new TypeError('Cannot construct a worker node without a worker')
- }
- if (tasksQueueBackPressureSize == null) {
- throw new TypeError(
- 'Cannot construct a worker node without a tasks queue back pressure size'
- )
- }
- if (!Number.isSafeInteger(tasksQueueBackPressureSize)) {
- throw new TypeError(
- 'Cannot construct a worker node with a tasks queue back pressure size that is not an integer'
- )
- }
- if (tasksQueueBackPressureSize <= 0) {
- throw new RangeError(
- 'Cannot construct a worker node with a tasks queue back pressure size that is not a positive integer'
- )
- }
- }
}