From 3875999b2642013dfddd6cb1fa7b3ee7ac14f9d7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 25 Jun 2020 08:05:00 +0200 Subject: Eliminate phase unlock for case where we are not going to wait --- libbuild2/context.ixx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libbuild2/context.ixx') diff --git a/libbuild2/context.ixx b/libbuild2/context.ixx index 46fe4f7..73601d4 100644 --- a/libbuild2/context.ixx +++ b/libbuild2/context.ixx @@ -56,8 +56,12 @@ namespace build2 inline void wait_guard:: wait () { - phase_unlock u (*ctx, phase); - ctx->sched.wait (start_count, *task_count); + if (task_count->load (memory_order_acquire) > start_count) + { + phase_unlock u (*ctx, phase); + ctx->sched.wait (start_count, *task_count); + } + task_count = nullptr; } } -- cgit v1.1