Skip to content

Commit 023bcde

Browse files
yashLadhaaddaleax
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: nodejs#32663 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent fea01c1 commit 023bcde

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/internal/cluster/master.js

Lines changed: 11 additions & 10 deletions
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)