Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYash Ladha <yashladhapankajladha123@gmail.com>2020-04-05 09:45:53 +0300
committerAnna Henningsen <anna@addaleax.net>2020-05-09 08:50:11 +0300
commit023bcdeb2848186192d2d3cd7ac33ff911b9a9ce (patch)
tree544dd3199e2bf94ae241ee290a12f437417ffe73 /lib/internal/cluster
parentfea01c11792cdbeca9a81525ed46a1b83192f802 (diff)
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>
Diffstat (limited to 'lib/internal/cluster')
-rw-r--r--lib/internal/cluster/master.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js
index 9d6d4df6316..9e2c7cbecb9 100644
--- a/lib/internal/cluster/master.js
+++ b/lib/internal/cluster/master.js
@@ -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;