From 0d3ce80a2f0cd8398225e7ef7a1abbe7e77a38fc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 3 Feb 2017 07:41:33 +0200 Subject: Add support for waiting on other threads task counts in scheduler --- build2/scheduler | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'build2/scheduler') diff --git a/build2/scheduler b/build2/scheduler index 563ec31..42f82e0 100644 --- a/build2/scheduler +++ b/build2/scheduler @@ -73,8 +73,11 @@ namespace build2 void async (atomic_count& task_count, F&&, A&&...); - // Wait until the task count reaches 0. If the scheduler is shutdown - // while waiting, throw system_error(ECANCELED). + // Wait until the task count reaches 0. If the scheduler is shutdown while + // waiting, throw system_error(ECANCELED). + // + // Note that it is valid to wait on another thread's task count (that is, + // without making any async() calls in this thread). // void wait (atomic_count& task_count); @@ -288,11 +291,15 @@ namespace build2 // depends on the number of waiters that we can have which cannot be // greater than the total number of threads. // + // The pointer to the task count is used to identify the already waiting + // group of threads for collision statistics. + // struct wait_slot { std::mutex mutex; std::condition_variable condv; size_t waiters = 0; + const atomic_count* tcount; bool shutdown = true; }; -- cgit v1.1