From 097722b1edef6dc094b375459b468445b587ebe1 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 22 Apr 2018 17:40:37 +0200 Subject: [PATCH] add API to get the number of threads in a threadpool --- ostd/build/make.hh | 4 ++++ ostd/thread_pool.hh | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ostd/build/make.hh b/ostd/build/make.hh index d5fe1c1..cfb2de6 100644 --- a/ostd/build/make.hh +++ b/ostd/build/make.hh @@ -251,6 +251,10 @@ struct make { return p_rules.back(); } + unsigned int threads() const noexcept { + return p_tpool.threads(); + } + private: struct rule_inst { diff --git a/ostd/thread_pool.hh b/ostd/thread_pool.hh index 6a573d8..4e2dbe5 100644 --- a/ostd/thread_pool.hh +++ b/ostd/thread_pool.hh @@ -196,6 +196,11 @@ struct thread_pool { return ret; } + /** @brief Gets the number of threads in the pool. */ + unsigned int threads() const noexcept { + return p_thrs.size(); + } + private: void thread_run() { for (;;) {