diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-05 12:13:04 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-05 12:13:04 +0200 |
commit | 7037e788eaee494f6d5536e9a9f51bd1ce9a762d (patch) | |
tree | 76d9b50ecfab9e1a1cabf005331520470f21b0d9 /libbuild2/context.cxx | |
parent | 44750a440fc376b68bcf042e41b5eeeea9549a91 (diff) |
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.
Diffstat (limited to 'libbuild2/context.cxx')
-rw-r--r-- | libbuild2/context.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
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. } |