]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd / ImageCtx: singleton thread pool instance helper
authorVenky Shankar <vshankar@redhat.com>
Fri, 24 Jun 2016 08:20:52 +0000 (13:50 +0530)
committerVenky Shankar <vshankar@redhat.com>
Sun, 7 Aug 2016 11:01:36 +0000 (16:31 +0530)
Introduce static member function in ImageCtx to fetch (and
initialize) singleton thread pool.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h

index df1d837a106bbd919660d1549f2b4609403cc464..56989fa1c974990d42d27e838774a54276b9eb30 100644 (file)
@@ -181,9 +181,7 @@ struct C_InvalidateCache : public Context {
 
     memset(&header, 0, sizeof(header));
 
-    ThreadPoolSingleton *thread_pool_singleton;
-    cct->lookup_or_create_singleton_object<ThreadPoolSingleton>(
-      thread_pool_singleton, "librbd::thread_pool");
+    ThreadPool *thread_pool_singleton = get_thread_pool_instance(cct);
     aio_work_queue = new AioImageRequestWQ(this, "librbd::aio_work_queue",
                                            cct->_conf->rbd_op_thread_timeout,
                                            thread_pool_singleton);
@@ -1044,4 +1042,11 @@ struct C_InvalidateCache : public Context {
     delete journal_policy;
     journal_policy = policy;
   }
+
+  ThreadPool *ImageCtx::get_thread_pool_instance(CephContext *cct) {
+    ThreadPoolSingleton *thread_pool_singleton;
+    cct->lookup_or_create_singleton_object<ThreadPoolSingleton>(
+      thread_pool_singleton, "librbd::thread_pool");
+    return thread_pool_singleton;
+  }
 }
index 7660f6e55467d900dc07888d83a658a08b603af2..fd580d9cc9fa4aee3e0cfe01e2613ff19a58731a 100644 (file)
@@ -32,6 +32,7 @@ class CephContext;
 class ContextWQ;
 class Finisher;
 class PerfCounters;
+class ThreadPool;
 
 namespace librbd {
 
@@ -300,6 +301,8 @@ namespace librbd {
 
     journal::Policy *get_journal_policy() const;
     void set_journal_policy(journal::Policy *policy);
+
+    static ThreadPool *get_thread_pool_instance(CephContext *cct);
   };
 }