]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/work_queue: make ThreadPool/WorkQueue more reusable.
authorIgor Fedotov <ifedotov@suse.com>
Sun, 8 Sep 2019 22:15:50 +0000 (01:15 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 18 Nov 2019 09:14:24 +0000 (12:14 +0300)
Some tricks to be able to derive from ThreadPool.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit e72801074c9d464044be3e981728c99618797984)

src/common/WorkQueue.h

index a978a6d698433f981175b1f95aa8cbec532838eb..2ccdd9a1036658ed676f15583da7f76a6fb544a6 100644 (file)
@@ -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<T *> m_items;
     uint32_t m_processing;
   };
-private:
+protected:
   std::vector<WorkQueue_*> 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);