clean unused codes

test=develop
release/1.1
Xin Pan 7 years ago
parent 784a19ecd0
commit 4f59690b4c

@ -52,8 +52,7 @@ void ThreadPool::Init() {
}
}
ThreadPool::ThreadPool(int num_threads)
: total_threads_(num_threads), idle_threads_(num_threads), running_(true) {
ThreadPool::ThreadPool(int num_threads) : running_(true) {
threads_.resize(num_threads);
for (auto& thread : threads_) {
// TODO(Yancey1989): binding the thread on the specify CPU number
@ -82,7 +81,6 @@ void ThreadPool::TaskLoop() {
scheduled_.wait(
lock, [this] { return !this->tasks_.empty() || !this->running_; });
std::lock_guard<std::mutex> l(mutex_);
if (!running_ || tasks_.empty()) {
return;
}
@ -90,8 +88,6 @@ void ThreadPool::TaskLoop() {
// pop a task from the task queue
auto task = std::move(tasks_.front());
tasks_.pop();
--idle_threads_;
lock.unlock();
// run the task

@ -107,14 +107,11 @@ class ThreadPool {
static std::once_flag init_flag_;
std::vector<std::unique_ptr<std::thread>> threads_;
const size_t total_threads_;
size_t idle_threads_;
std::queue<Task> tasks_;
std::mutex mutex_;
bool running_;
std::condition_variable scheduled_;
std::condition_variable completed_;
};
class ThreadPoolIO : ThreadPool {

Loading…
Cancel
Save