aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-01 07:31:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:41 +0200
commit1dd17210b76d544a04fc6b4f3c98162ae9718102 (patch)
tree7ace5831f71fcc4696a38fe0a3cd608e626df90e
parent9d6583056a82829f4512e6ba6a471a9b3e86a4a5 (diff)
Fix scheduler::tune() to wait for active threads coming off
-rw-r--r--build2/scheduler.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/build2/scheduler.cxx b/build2/scheduler.cxx
index da49ffd..47d38e4 100644
--- a/build2/scheduler.cxx
+++ b/build2/scheduler.cxx
@@ -223,9 +223,16 @@ namespace build2
assert (max_active >= init_active_ &&
max_active <= orig_max_active_);
- // The schduler must not be active.
+ // The scheduler must not be active though some threads might still be
+ // comming off from finishing a task. So we busy-wait for them.
//
- assert (active_ == init_active_);
+ while (active_ != init_active_)
+ {
+ l.unlock ();
+ this_thread::yield ();
+ l.lock ();
+ }
+
assert (waiting_ == 0);
assert (ready_ == 0);