From 88379eedeae654391711d8cdda17dfc2be6367ef Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 12 May 2021 10:46:21 +0200 Subject: Keep phase locked while working own queue --- libbuild2/algorithm.cxx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'libbuild2/algorithm.cxx') 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; -- cgit v1.1