- protected assignChosenWorkerNodeKey (
- chosenWorkerNodeKey: number | undefined
- ): void {
- if (chosenWorkerNodeKey != null) {
- this.nextWorkerNodeKey = chosenWorkerNodeKey
- } else {
- this.nextWorkerNodeKey = undefined
- }
- }
-
- protected checkNextWorkerNodeEligibility (
- chosenWorkerNodeKey: number | undefined
- ): void {
- if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
- this.nextWorkerNodeKey = undefined
- this.previousWorkerNodeKey =
- chosenWorkerNodeKey ?? this.previousWorkerNodeKey
- }
- }
-
- protected computeDefaultWorkerWeight (): number {
- let cpusCycleTimeWeight = 0
- for (const cpu of cpus()) {
- // CPU estimated cycle time
- const numberOfDigits = cpu.speed.toString().length - 1
- const cpuCycleTime = 1 / (cpu.speed / Math.pow(10, numberOfDigits))
- cpusCycleTimeWeight += cpuCycleTime * Math.pow(10, numberOfDigits)
- }
- return Math.round(cpusCycleTimeWeight / cpus().length)
+ protected setPreviousWorkerNodeKey (workerNodeKey: number | undefined): void {
+ this.previousWorkerNodeKey =
+ workerNodeKey != null && workerNodeKey >= 0
+ ? workerNodeKey
+ : this.previousWorkerNodeKey