diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-03 07:41:33 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-13 12:42:41 +0200 |
commit | 0d3ce80a2f0cd8398225e7ef7a1abbe7e77a38fc (patch) | |
tree | ddc78f3db07d5ba2cbccde7b62e95df8be099bc0 /build2/scheduler | |
parent | 63f6a8256e3f9fb47cb941be63baa70e2be48d3b (diff) |
Add support for waiting on other threads task counts in scheduler
Diffstat (limited to 'build2/scheduler')
-rw-r--r-- | build2/scheduler | 11 |
1 files changed, 9 insertions, 2 deletions
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; }; |