Skip to content

Commit

Permalink
common/WorkQueue: add std move
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
  • Loading branch information
stiopaa1 committed Jun 15, 2016
1 parent 281e74d commit 4ab3f4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
18 changes: 14 additions & 4 deletions src/common/WorkQueue.cc
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
{
Expand Down
11 changes: 6 additions & 5 deletions src/common/WorkQueue.h
Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 4ab3f4e

Please sign in to comment.