From 21e6573d49997cccc96e197d784aeacf10bdc919 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Fri, 24 Jun 2016 13:50:52 +0530 Subject: [PATCH] librbd / ImageCtx: singleton thread pool instance helper Introduce static member function in ImageCtx to fetch (and initialize) singleton thread pool. Signed-off-by: Venky Shankar --- src/librbd/ImageCtx.cc | 11 ++++++++--- src/librbd/ImageCtx.h | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index df1d837a106..56989fa1c97 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -181,9 +181,7 @@ struct C_InvalidateCache : public Context { memset(&header, 0, sizeof(header)); - ThreadPoolSingleton *thread_pool_singleton; - cct->lookup_or_create_singleton_object( - 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( + thread_pool_singleton, "librbd::thread_pool"); + return thread_pool_singleton; + } } diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 7660f6e5546..fd580d9cc9f 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -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); }; } -- 2.39.5