mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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: https://github.com/nodejs/node/pull/32663 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
548cedd870
commit
94d0a088ec
1 file changed
+11
-10
@@ -37,16 +37,17 @@ let debugPortOffset = 1;
|
||||
let initialized = false;
|
||||
|
||||
// XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings?
|
||||
let schedulingPolicy = {
|
||||
'none': SCHED_NONE,
|
||||
'rr': SCHED_RR
|
||||
}[process.env.NODE_CLUSTER_SCHED_POLICY];
|
||||
|
||||
if (schedulingPolicy === undefined) {
|
||||
// FIXME Round-robin doesn't perform well on Windows right now due to the
|
||||
// way IOCP is wired up.
|
||||
schedulingPolicy = (process.platform === 'win32') ? SCHED_NONE : SCHED_RR;
|
||||
}
|
||||
let schedulingPolicy = process.env.NODE_CLUSTER_SCHED_POLICY;
|
||||
if (schedulingPolicy === 'rr')
|
||||
schedulingPolicy = SCHED_RR;
|
||||
else if (schedulingPolicy === 'none')
|
||||
schedulingPolicy = SCHED_NONE;
|
||||
else if (process.platform === 'win32') {
|
||||
// Round-robin doesn't perform well on
|
||||
// Windows due to the way IOCP is wired up.
|
||||
schedulingPolicy = SCHED_NONE;
|
||||
} else
|
||||
schedulingPolicy = SCHED_RR;
|
||||
|
||||
cluster.schedulingPolicy = schedulingPolicy;
|
||||
|
||||
|
||||
Reference in new issue
Block a user