From 7037e788eaee494f6d5536e9a9f51bd1ce9a762d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 5 May 2021 12:13:04 +0200 Subject: Deactivate when blocked on load phase mutex This turned out to be important when building in multiple contexts that share the scheduler (e.g., main and module/recipe build context). In this case we need an accurate active thread count in order to decide when to start an extra helper thread past max_active. --- libbuild2/context.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'libbuild2/context.cxx') diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx index 09ab15d..b4ba5df 100644 --- a/libbuild2/context.cxx +++ b/libbuild2/context.cxx @@ -664,7 +664,12 @@ namespace build2 // if (p == run_phase::load) { - lm_.lock (); + if (!lm_.try_lock ()) + { + ctx_.sched.deactivate (false /* external */); + lm_.lock (); + ctx_.sched.activate (false /* external */); + } r = !fail_; // Re-query. } @@ -773,7 +778,12 @@ namespace build2 if (n == run_phase::load) { - lm_.lock (); + if (!lm_.try_lock ()) + { + ctx_.sched.deactivate (false /* external */); + lm_.lock (); + ctx_.sched.activate (false /* external */); + } r = !fail_; // Re-query. } -- cgit v1.1