From 75f0bb9e7bbdea0fa6d15d253139f0583be6abea 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 (cherry picked from commit 2d90bd8fdb30705d05569d242fc0cc4e36a2c7db) Conflicts: src/common/WorkQueue.h: trivial resolution src/librbd/AioImageRequestWQ.cc: file renamed --- src/common/WorkQueue.h | 5 ++++- src/librbd/AioImageRequestWQ.cc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index bffe12b58fae0..cb6d111231a7e 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_(n, ti, sti), m_pool(p), m_processing(0) { } + void register_work_queue() { + m_pool->add_work_queue(this); + } virtual void _clear() { 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/AioImageRequestWQ.cc b/src/librbd/AioImageRequestWQ.cc index f9942ce20596a..a81d49ee90da6 100644 --- a/src/librbd/AioImageRequestWQ.cc +++ b/src/librbd/AioImageRequestWQ.cc @@ -66,7 +66,7 @@ AioImageRequestWQ::AioImageRequestWQ(I *image_ctx, const string &name, m_lock(util::unique_lock_name("AioImageRequestWQ::m_lock", this)) { CephContext *cct = m_image_ctx.cct; ldout(cct, 5) << this << " " << ": ictx=" << image_ctx << dendl; - tp->add_work_queue(this); + this->register_work_queue(); } template -- 2.39.5