Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
clang-format.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbutrovich committed Jun 27, 2018
1 parent 8aee4ea commit 52e1a96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/threadpool/worker_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "common/logger.h"


namespace peloton {
namespace threadpool {

Expand All @@ -25,12 +24,12 @@ namespace {
void WorkerFunc(std::string thread_name, std::atomic_bool *is_running,
TaskQueue *task_queue, std::mutex *cv_lock,
std::condition_variable *not_empty) {

LOG_INFO("Thread %s starting ...", thread_name.c_str());

while (is_running->load() || !task_queue->IsEmpty()) {
std::unique_lock<std::mutex> lock(*cv_lock);
not_empty->wait_for(lock, std::chrono::milliseconds(1), [&]{return !task_queue->IsEmpty();});
not_empty->wait_for(lock, std::chrono::milliseconds(1),
[&] { return !task_queue->IsEmpty(); });
std::function<void()> task;
if (task_queue->Dequeue(task)) {
lock.unlock();
Expand All @@ -55,7 +54,8 @@ void WorkerPool::Startup() {
if (is_running_.compare_exchange_strong(running, true)) {
for (size_t i = 0; i < num_workers_; i++) {
std::string name = pool_name_ + "-worker-" + std::to_string(i);
workers_.emplace_back(WorkerFunc, name, &is_running_, &task_queue_, &cv_lock, &not_empty);
workers_.emplace_back(WorkerFunc, name, &is_running_, &task_queue_,
&cv_lock, &not_empty);
}
}
}
Expand Down

0 comments on commit 52e1a96

Please sign in to comment.