From: Mikko Rasa Date: Thu, 19 Jul 2012 10:41:40 +0000 (+0300) Subject: Improve task management to use blocking wait if possible X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f515e91176cb4fcb1df379cdf664c90b3a565c95;p=builder.git Improve task management to use blocking wait if possible --- diff --git a/source/builder.cpp b/source/builder.cpp index df7edab..7b0f018 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -457,10 +457,11 @@ int Builder::do_build() bool fail = false; bool finish = false; + bool starved = false; while(!finish) { - if(tasks.size()get_buildable_target(); if(tgt) @@ -488,13 +489,20 @@ int Builder::do_build() } else if(tasks.empty()) finish = true; + else + starved = true; } else Time::sleep(10*Time::msec); for(unsigned i=0; icheck(); + Task::Status status; + if(jobs==1 || (tasks.size()==1 && starved)) + status = tasks[i]->wait(); + else + status = tasks[i]->check(); + if(status!=Task::RUNNING) { ++count; @@ -505,6 +513,7 @@ int Builder::do_build() fail = true; if(tasks.empty() && fail) finish = true; + starved = false; } else ++i;