aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/algorithm.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/algorithm.cxx
parent8b858c642ccab43050dcff2d8f98db469ac6dc1b (diff)
Keep phase locked while working own queue
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r--libbuild2/algorithm.cxx16
1 files changed, 5 insertions, 11 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx
index 5e93935..a19a6a0 100644
--- a/libbuild2/algorithm.cxx
+++ b/libbuild2/algorithm.cxx
@@ -236,8 +236,8 @@ namespace build2
// to switch the phase to load. Which would result in a deadlock
// unless we release the phase.
//
- phase_unlock ul (ct.ctx);
- e = ctx.sched.wait (busy - 1, task_count, *wq);
+ phase_unlock u (ct.ctx, true /* unlock */, true /* delay */);
+ e = ctx.sched.wait (busy - 1, task_count, u, *wq);
}
// We don't lock already applied or executed targets.
@@ -2015,9 +2015,7 @@ namespace build2
// If the target is still busy, wait for its completion.
//
- const auto& tc (mt[a].task_count);
- if (tc.load (memory_order_acquire) >= busy)
- ctx.sched.wait (exec, tc, scheduler::work_none);
+ ctx.sched.wait (exec, mt[a].task_count, scheduler::work_none);
r |= mt.executed_state (a);
@@ -2067,9 +2065,7 @@ namespace build2
const target& mt (*ts[i]);
- const auto& tc (mt[a].task_count);
- if (tc.load (memory_order_acquire) >= busy)
- ctx.sched.wait (exec, tc, scheduler::work_none);
+ ctx.sched.wait (exec, mt[a].task_count, scheduler::work_none);
r |= mt.executed_state (a);
@@ -2151,9 +2147,7 @@ namespace build2
const target& pt (*p.target);
- const auto& tc (pt[a].task_count);
- if (tc.load (memory_order_acquire) >= busy)
- ctx.sched.wait (exec, tc, scheduler::work_none);
+ ctx.sched.wait (exec, pt[a].task_count, scheduler::work_none);
target_state s (pt.executed_state (a));
rs |= s;