From 1dd17210b76d544a04fc6b4f3c98162ae9718102 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 1 Feb 2017 07:31:48 +0200 Subject: Fix scheduler::tune() to wait for active threads coming off --- build2/scheduler.cxx | 11 +++++++++-- 1 file 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); -- cgit v1.1