From cef4e41bf29ce51e3b86c899b3acc970046a3b73 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Mon, 9 Sep 2019 01:15:50 +0300 Subject: [PATCH] common/work_queue: make ThreadPool/WorkQueue more reusable. Some tricks to be able to derive from ThreadPool. Signed-off-by: Igor Fedotov (cherry picked from commit e72801074c9d464044be3e981728c99618797984) --- src/common/WorkQueue.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index a978a6d698433..2ccdd9a103665 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -41,6 +41,7 @@ class CephContext; /// Pool of threads that share work submitted to multiple work queues. class ThreadPool : public md_config_obs_t { +protected: CephContext *cct; std::string name; std::string thread_name; @@ -69,7 +70,7 @@ public: void reset_tp_timeout(); void suspend_tp_timeout(); }; -private: +protected: /// Basic interface to a work queue used by the worker threads. struct WorkQueue_ { @@ -450,7 +451,7 @@ public: std::list m_items; uint32_t m_processing; }; -private: +protected: std::vector work_queues; int next_work_queue = 0; @@ -472,7 +473,7 @@ private: void start_threads(); void join_old_threads(); - void worker(WorkThread *wt); + virtual void worker(WorkThread *wt); public: ThreadPool(CephContext *cct_, std::string nm, std::string tn, int n, const char *option = NULL); -- 2.39.5