summaryrefslogtreecommitdiffstats
path: root/src/build.cc
diff options
context:
space:
mode:
authortzik <tzik@chromium.org>2014-09-19 08:07:29 (GMT)
committertzik <tzik@chromium.org>2014-09-22 04:03:31 (GMT)
commit2cb9d7c2d6df859ab26b22472adbf979e28aeedd (patch)
tree9da551349fd3cb1af7d0553fddf824be21886745 /src/build.cc
parent0d6a4e920b1b91d7837335e7fbbe9014d5b316a4 (diff)
downloadNinja-2cb9d7c2d6df859ab26b22472adbf979e28aeedd.zip
Ninja-2cb9d7c2d6df859ab26b22472adbf979e28aeedd.tar.gz
Ninja-2cb9d7c2d6df859ab26b22472adbf979e28aeedd.tar.bz2
Throttle the number of pending commands by the parallelism configuration
Diffstat (limited to 'src/build.cc')
-rw-r--r--src/build.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/build.cc b/src/build.cc
index 64bcea3..fb1cc74 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -488,7 +488,9 @@ void RealCommandRunner::Abort() {
}
bool RealCommandRunner::CanRunMore() {
- return ((int)subprocs_.running_.size()) < config_.parallelism
+ size_t subproc_number =
+ subprocs_.running_.size() + subprocs_.finished_.size();
+ return (int)subproc_number < config_.parallelism
&& ((subprocs_.running_.empty() || config_.max_load_average <= 0.0f)
|| GetLoadAverage() < config_.max_load_average);
}