diff options
author | Evan Martin <martine@danga.com> | 2011-02-01 18:18:16 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-02-01 18:18:16 (GMT) |
commit | 2baf05d2b80c5b852ee718f272446ceba572b9cc (patch) | |
tree | 20ccba8228261cb4678f70a443cc319d93ba7452 /src | |
parent | 0d0f186053087c3705ee4c01f6b7f4bf7832c063 (diff) | |
download | Ninja-2baf05d2b80c5b852ee718f272446ceba572b9cc.zip Ninja-2baf05d2b80c5b852ee718f272446ceba572b9cc.tar.gz Ninja-2baf05d2b80c5b852ee718f272446ceba572b9cc.tar.bz2 |
implement parallelism flag
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/build.cc b/src/build.cc index a75659a..8e567d9 100644 --- a/src/build.cc +++ b/src/build.cc @@ -182,19 +182,20 @@ void Plan::Dump() { } struct RealCommandRunner : public CommandRunner { + RealCommandRunner(int parallelism) : parallelism_(parallelism) {} virtual ~RealCommandRunner() {} virtual bool CanRunMore(); virtual bool StartCommand(Edge* edge); virtual bool WaitForCommands(); virtual Edge* NextFinishedCommand(bool* success); + int parallelism_; SubprocessSet subprocs_; map<Subprocess*, Edge*> subproc_to_edge_; }; bool RealCommandRunner::CanRunMore() { - const size_t kConcurrency = 8; // XXX make configurable etc. - return subprocs_.running_.size() < kConcurrency; + return ((int)subprocs_.running_.size()) < parallelism_; } bool RealCommandRunner::StartCommand(Edge* edge) { @@ -270,7 +271,7 @@ Builder::Builder(State* state, const BuildConfig& config) if (config.dry_run) command_runner_ = new DryRunCommandRunner; else - command_runner_ = new RealCommandRunner; + command_runner_ = new RealCommandRunner(config.parallelism); status_ = new BuildStatus; status_->verbosity_ = config.verbosity; log_ = state->build_log_; |