Skip to content

Commit 94d0a08

Browse files
yashLadhacodebytere
authored andcommitted
lib: refactored scheduling policy assignment
In previous implementation it was clubbed into declaration of scheduling policies and fetching the schedulingPolicy. Now they are separate variables, so that in future if one want to add new scheduling policy. It is much simpler and not obsfucated. PR-URL: #32663 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 548cedd commit 94d0a08

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/internal/cluster/master.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ let debugPortOffset = 1;
3737
let initialized = false;
3838

3939
// XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings?
40-
let schedulingPolicy = {
41-
'none': SCHED_NONE,
42-
'rr': SCHED_RR
43-
}[process.env.NODE_CLUSTER_SCHED_POLICY];
44-
45-
if (schedulingPolicy === undefined) {
46-
// FIXME Round-robin doesn't perform well on Windows right now due to the
47-
// way IOCP is wired up.
48-
schedulingPolicy = (process.platform === 'win32') ? SCHED_NONE : SCHED_RR;
49-
}
40+
let schedulingPolicy = process.env.NODE_CLUSTER_SCHED_POLICY;
41+
if (schedulingPolicy === 'rr')
42+
schedulingPolicy = SCHED_RR;
43+
else if (schedulingPolicy === 'none')
44+
schedulingPolicy = SCHED_NONE;
45+
else if (process.platform === 'win32') {
46+
// Round-robin doesn't perform well on
47+
// Windows due to the way IOCP is wired up.
48+
schedulingPolicy = SCHED_NONE;
49+
} else
50+
schedulingPolicy = SCHED_RR;
5051

5152
cluster.schedulingPolicy = schedulingPolicy;
5253

0 commit comments

Comments
 (0)