From 2baf05d2b80c5b852ee718f272446ceba572b9cc Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Tue, 1 Feb 2011 10:18:16 -0800 Subject: implement parallelism flag --- src/build.cc | 7 ++++--- todo | 2 -- 2 files changed, 4 insertions(+), 5 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 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_; diff --git a/todo b/todo index b97df0d..e3e0acb 100644 --- a/todo +++ b/todo @@ -3,8 +3,6 @@ necessary website, contact info --j flag for parallelism - delete halfway-built output files when interrupted frosting -- cgit v0.12