aboutsummaryrefslogtreecommitdiff
path: root/build2/scheduler.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-03 08:17:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:41 +0200
commit21c5af3dc018ec1f2218a3df3c8195cfcfe3aefa (patch)
treed0f0ac84592ff12144b7b52dea8ac2dbb2aaa04d /build2/scheduler.cxx
parent0d3ce80a2f0cd8398225e7ef7a1abbe7e77a38fc (diff)
Add support for passing alternative task start counts to scheduler
Diffstat (limited to 'build2/scheduler.cxx')
-rw-r--r--build2/scheduler.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/build2/scheduler.cxx b/build2/scheduler.cxx
index c151847..ee0f4a2 100644
--- a/build2/scheduler.cxx
+++ b/build2/scheduler.cxx
@@ -11,9 +11,9 @@ using namespace std;
namespace build2
{
void scheduler::
- wait (atomic_count& task_count)
+ wait (size_t start_count, atomic_count& task_count)
{
- if (task_count == 0)
+ if (task_count == start_count)
return;
// See if we can run some of our own tasks.
@@ -29,15 +29,15 @@ namespace build2
// Note that empty task queue doesn't automatically mean the task count
// is zero (some might still be executing asynchronously).
//
- if (task_count == 0)
+ if (task_count == start_count)
return;
}
- suspend (task_count);
+ suspend (start_count, task_count);
}
void scheduler::
- suspend (atomic_count& tc)
+ suspend (size_t start_count, atomic_count& tc)
{
wait_slot& s (
wait_queue_[std::hash<atomic_count*> () (&tc) % wait_queue_size_]);
@@ -85,7 +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) != 0)
+ while (!s.shutdown &&
+ tc.load (std::memory_order_relaxed) != start_count)
s.condv.wait (l);
s.waiters--;