diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc index 6fc468ab5c125..6141057b0dd78 100644 --- a/src/common/WorkQueue.cc +++ b/src/common/WorkQueue.cc @@ -28,7 +28,7 @@ ThreadPool::ThreadPool(CephContext *cct_, string nm, string tn, int n, const char *option) - : cct(cct_), name(nm), thread_name(tn), + : cct(cct_), name(std::move(nm)), thread_name(std::move(tn)), lockname(nm + "::lock"), _lock(lockname.c_str()), // this should be safe due to declaration order _stop(false), @@ -291,9 +291,19 @@ void ThreadPool::set_ioprio(int cls, int priority) } ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, string nm, string tn, - uint32_t pnum_threads): cct(pcct_),name(nm),thread_name(tn),lockname(nm + "::lock"), - shardedpool_lock(lockname.c_str()),num_threads(pnum_threads),stop_threads(0), - pause_threads(0),drain_threads(0), num_paused(0), num_drained(0), wq(NULL) {} + uint32_t pnum_threads): + cct(pcct_), + name(std::move(nm)), + thread_name(std::move(tn)), + lockname(name + "::lock"), + shardedpool_lock(lockname.c_str()), + num_threads(pnum_threads), + stop_threads(0), + pause_threads(0), + drain_threads(0), + num_paused(0), + num_drained(0), + wq(NULL) {} void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index) { diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index bdb285ef56199..18427b48c0cac 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -62,7 +62,7 @@ class ThreadPool : public md_config_obs_t { string name; time_t timeout_interval, suicide_interval; WorkQueue_(string n, time_t ti, time_t sti) - : name(n), timeout_interval(ti), suicide_interval(sti) + : name(std::move(n)), timeout_interval(ti), suicide_interval(sti) { } virtual ~WorkQueue_() {} /// Remove all work items from the queue. @@ -130,7 +130,7 @@ class ThreadPool : public md_config_obs_t { public: BatchWorkQueue(string n, time_t ti, time_t sti, ThreadPool* p) - : WorkQueue_(n, ti, sti), pool(p) { + : WorkQueue_(std::move(n), ti, sti), pool(p) { pool->add_work_queue(this); } ~BatchWorkQueue() { @@ -228,7 +228,7 @@ class ThreadPool : public md_config_obs_t { public: WorkQueueVal(string n, time_t ti, time_t sti, ThreadPool *p) - : WorkQueue_(n, ti, sti), _lock("WorkQueueVal::lock"), pool(p) { + : WorkQueue_(std::move(n), ti, sti), _lock("WorkQueueVal::lock"), pool(p) { pool->add_work_queue(this); } ~WorkQueueVal() { @@ -290,7 +290,8 @@ class ThreadPool : public md_config_obs_t { virtual void _process(T *t, TPHandle &) = 0; public: - WorkQueue(string n, time_t ti, time_t sti, ThreadPool* p) : WorkQueue_(n, ti, sti), pool(p) { + WorkQueue(string n, time_t ti, time_t sti, ThreadPool* p) + : WorkQueue_(std::move(n), ti, sti), pool(p) { pool->add_work_queue(this); } ~WorkQueue() { @@ -371,7 +372,7 @@ class ThreadPool : public md_config_obs_t { } protected: PointerWQ(string n, time_t ti, time_t sti, ThreadPool* p) - : WorkQueue_(n, ti, sti), m_pool(p), m_processing(0) { + : WorkQueue_(std::move(n), ti, sti), m_pool(p), m_processing(0) { } virtual void _clear() { assert(m_pool->_lock.is_locked());