aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-03 09:29:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:41 +0200
commit0e4b975073a787ce3e5450173cf407a71bafd3a4 (patch)
tree7a810b6d108f4bce8659965a0dfebd6bd0b7f093 /build2
parent21c5af3dc018ec1f2218a3df3c8195cfcfe3aefa (diff)
Use less-than test for start count in scheduler
Diffstat (limited to 'build2')
-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.
}
}