From f515e91176cb4fcb1df379cdf664c90b3a565c95 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 19 Jul 2012 13:41:40 +0300 Subject: [PATCH] Improve task management to use blocking wait if possible --- source/builder.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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; -- 2.45.2