aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/scheduler.cxx10
-rw-r--r--build2/scheduler.txx2
2 files changed, 6 insertions, 6 deletions
diff --git a/build2/scheduler.cxx b/build2/scheduler.cxx
index ee0f4a2..d1fdf26 100644
--- a/build2/scheduler.cxx
+++ b/build2/scheduler.cxx
@@ -13,7 +13,7 @@ namespace build2
void scheduler::
wait (size_t start_count, atomic_count& task_count)
{
- if (task_count == start_count)
+ if (task_count <= start_count)
return;
// See if we can run some of our own tasks.
@@ -27,9 +27,9 @@ namespace build2
pop_back (*tq, ql);
// Note that empty task queue doesn't automatically mean the task count
- // is zero (some might still be executing asynchronously).
+ // has been decremented (some might still be executing asynchronously).
//
- if (task_count == start_count)
+ if (task_count <= start_count)
return;
}
@@ -85,8 +85,8 @@ namespace build2
// Since we use a mutex for synchronization, we can relax the atomic
// access.
//
- while (!s.shutdown &&
- tc.load (std::memory_order_relaxed) != start_count)
+ while (!(s.shutdown ||
+ tc.load (std::memory_order_relaxed) <= start_count))
s.condv.wait (l);
s.waiters--;
diff --git a/build2/scheduler.txx b/build2/scheduler.txx
index 965813f..01408ca 100644
--- a/build2/scheduler.txx
+++ b/build2/scheduler.txx
@@ -86,7 +86,7 @@ namespace build2
t.thunk (std::index_sequence_for<A...> ());
atomic_count& tc (*t.task_count);
- if (--tc == t.start_count)
+ if (--tc <= t.start_count)
s.resume (tc); // Resume a waiter, if any.
}
}