aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scheduler.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-05-12 10:46:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-05-12 16:30:12 +0200
commit88379eedeae654391711d8cdda17dfc2be6367ef (patch)
tree966ee03369b51013021600a2beea8334962ab2ec /libbuild2/scheduler.cxx
parent8b858c642ccab43050dcff2d8f98db469ac6dc1b (diff)
Keep phase locked while working own queue
Diffstat (limited to 'libbuild2/scheduler.cxx')
-rw-r--r--libbuild2/scheduler.cxx15
1 files changed, 5 insertions, 10 deletions
diff --git a/libbuild2/scheduler.cxx b/libbuild2/scheduler.cxx
index deb5399..43da681 100644
--- a/libbuild2/scheduler.cxx
+++ b/libbuild2/scheduler.cxx
@@ -50,16 +50,9 @@ namespace build2
scheduler_queue = q;
}
- size_t scheduler::
- wait (size_t start_count, const atomic_count& task_count, work_queue wq)
+ optional<size_t> scheduler::
+ wait_impl (size_t start_count, const atomic_count& task_count, work_queue wq)
{
- // Note that task_count is a synchronization point.
- //
- size_t tc;
-
- if ((tc = task_count.load (memory_order_acquire)) <= start_count)
- return tc;
-
assert (max_active_ != 1); // Serial execution, nobody to wait for.
// See if we can run some of our own tasks.
@@ -71,6 +64,8 @@ namespace build2
//
if (task_queue* tq = queue ())
{
+ size_t tc;
+
for (lock ql (tq->mutex); !tq->shutdown && !empty_back (*tq); )
{
pop_back (*tq, ql);
@@ -91,7 +86,7 @@ namespace build2
}
}
- return suspend (start_count, task_count);
+ return nullopt;
}
void scheduler::