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/scheduler.hxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libbuild2/scheduler.hxx') diff --git a/libbuild2/scheduler.hxx b/libbuild2/scheduler.hxx index e1bb715..9556caa 100644 --- a/libbuild2/scheduler.hxx +++ b/libbuild2/scheduler.hxx @@ -125,6 +125,16 @@ namespace build2 return wait (0, task_count, wq); } + // As above but call lock.unlock() before suspending (can be used to + // unlock the phase). + // + template + size_t + wait (size_t start_count, + const atomic_count& task_count, + L& lock, + work_queue = work_all); + // Mark the queue so that we don't work any tasks that may already be // there. In the normal "bunch of acync() calls followed by wait()" // cases this happens automatically but in special cases where async() @@ -846,6 +856,10 @@ namespace build2 static void queue (task_queue*) noexcept; + + private: + optional + wait_impl (size_t, const atomic_count&, work_queue); }; } -- cgit v1.1