From 4f59690b4c3519578258cb5748e4e5e653a0d429 Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Wed, 24 Oct 2018 21:44:51 +0800 Subject: [PATCH] clean unused codes test=develop --- paddle/fluid/framework/threadpool.cc | 6 +----- paddle/fluid/framework/threadpool.h | 3 --- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/paddle/fluid/framework/threadpool.cc b/paddle/fluid/framework/threadpool.cc index 3d42aea22..defbd7625 100644 --- a/paddle/fluid/framework/threadpool.cc +++ b/paddle/fluid/framework/threadpool.cc @@ -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 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 diff --git a/paddle/fluid/framework/threadpool.h b/paddle/fluid/framework/threadpool.h index 459aba9ef..745dcc7c7 100644 --- a/paddle/fluid/framework/threadpool.h +++ b/paddle/fluid/framework/threadpool.h @@ -107,14 +107,11 @@ class ThreadPool { static std::once_flag init_flag_; std::vector> threads_; - const size_t total_threads_; - size_t idle_threads_; std::queue tasks_; std::mutex mutex_; bool running_; std::condition_variable scheduled_; - std::condition_variable completed_; }; class ThreadPoolIO : ThreadPool { -- GitLab