From 2d90bd8fdb30705d05569d242fc0cc4e36a2c7db Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 22 Jun 2017 13:31:10 -0400 Subject: [PATCH] common: improve the ability to mock PointerWQ classes Signed-off-by: Jason Dillaman --- src/common/WorkQueue.h | 5 ++++- src/librbd/io/ImageRequestWQ.cc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index c817e74ec09..d3eff47bdf8 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -373,6 +373,9 @@ public: PointerWQ(string n, time_t ti, time_t sti, ThreadPool* p) : WorkQueue_(std::move(n), ti, sti), m_pool(p), m_processing(0) { } + void register_work_queue() { + m_pool->add_work_queue(this); + } void _clear() override { assert(m_pool->_lock.is_locked()); m_items.clear(); @@ -576,7 +579,7 @@ public: ContextWQ(const string &name, time_t ti, ThreadPool *tp) : ThreadPool::PointerWQ(name, ti, 0, tp), m_lock("ContextWQ::m_lock") { - tp->add_work_queue(this); + this->register_work_queue(); } void queue(Context *ctx, int result = 0) { diff --git a/src/librbd/io/ImageRequestWQ.cc b/src/librbd/io/ImageRequestWQ.cc index 8b59964e94c..593301c5abc 100644 --- a/src/librbd/io/ImageRequestWQ.cc +++ b/src/librbd/io/ImageRequestWQ.cc @@ -69,7 +69,7 @@ ImageRequestWQ::ImageRequestWQ(I *image_ctx, const string &name, m_lock(util::unique_lock_name("ImageRequestWQ::m_lock", this)) { CephContext *cct = m_image_ctx.cct; ldout(cct, 5) << "ictx=" << image_ctx << dendl; - tp->add_work_queue(this); + this->register_work_queue(); } template -- 2.47.3