use underscore at end of private members names

This commit is contained in:
gabime 2018-05-26 19:02:20 +03:00
parent 7a339e2b5e
commit b002a21c36
1 changed files with 9 additions and 9 deletions

View File

@ -89,7 +89,7 @@ public:
thread_pool(size_t q_size_bytes, size_t threads_n) thread_pool(size_t q_size_bytes, size_t threads_n)
: msg_counter_(0) : msg_counter_(0)
, _q(q_size_bytes) , q_(q_size_bytes)
{ {
// std::cout << "thread_pool() q_size_bytes: " << q_size_bytes << "\tthreads_n: " << threads_n << std::endl; // std::cout << "thread_pool() q_size_bytes: " << q_size_bytes << "\tthreads_n: " << threads_n << std::endl;
if (threads_n == 0 || threads_n > 1000) if (threads_n == 0 || threads_n > 1000)
@ -98,7 +98,7 @@ public:
} }
for (size_t i = 0; i < threads_n; i++) for (size_t i = 0; i < threads_n; i++)
{ {
_threads.emplace_back(std::bind(&thread_pool::worker_loop, this)); threads_.emplace_back(std::bind(&thread_pool::worker_loop, this));
} }
} }
@ -107,12 +107,12 @@ public:
{ {
try try
{ {
for (size_t i = 0; i < _threads.size(); i++) for (size_t i = 0; i < threads_.size(); i++)
{ {
post_async_msg(async_msg(async_msg_type::terminate), async_overflow_policy::block_retry); post_async_msg(async_msg(async_msg_type::terminate), async_overflow_policy::block_retry);
} }
for (auto &t : _threads) for (auto &t : threads_)
{ {
t.join(); t.join();
} }
@ -141,19 +141,19 @@ public:
private: private:
std::atomic<size_t> msg_counter_; // total # of messages processed in this pool std::atomic<size_t> msg_counter_; // total # of messages processed in this pool
q_type _q; q_type q_;
std::vector<std::thread> _threads; std::vector<std::thread> threads_;
void post_async_msg(async_msg &&new_msg, async_overflow_policy overflow_policy) void post_async_msg(async_msg &&new_msg, async_overflow_policy overflow_policy)
{ {
if (overflow_policy == async_overflow_policy::block_retry) if (overflow_policy == async_overflow_policy::block_retry)
{ {
_q.enqueue(std::move(new_msg)); q_.enqueue(std::move(new_msg));
} }
else else
{ {
_q.enqueue_nowait(std::move(new_msg)); q_.enqueue_nowait(std::move(new_msg));
} }
} }
@ -167,7 +167,7 @@ private:
bool process_next_msg() bool process_next_msg()
{ {
async_msg incoming_async_msg; async_msg incoming_async_msg;
bool dequeued = _q.dequeue_for(incoming_async_msg, std::chrono::seconds(10)); bool dequeued = q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10));
if (!dequeued) if (!dequeued)
{ {
return true; return true;