diff --git a/paddle/fluid/framework/threadpool.cc b/paddle/fluid/framework/threadpool.cc index 3d42aea229dbd26fa69a593babe10f76b478c1e2..defbd7625d0ca5fdc57f4d7e511a8f10a5452e2f 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 459aba9ef41039a3423a9dd93b2689a94916c774..745dcc7c7d4a20ad1c8b4023f360a0ccda076114 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 {