diff --git a/paddle/fluid/framework/threadpool.cc b/paddle/fluid/framework/threadpool.cc index 3041fbe5a844b565d48f013dd562359333703d5b..a588cb417aebe94bd4aeda02b1bc8ba07a04b960 100644 --- a/paddle/fluid/framework/threadpool.cc +++ b/paddle/fluid/framework/threadpool.cc @@ -25,22 +25,14 @@ DEFINE_int32(dist_threadpool_size, 0, namespace paddle { namespace framework { -std::mutex threadpool_mu; std::unique_ptr ThreadPool::threadpool_(nullptr); std::once_flag ThreadPool::init_flag_; ThreadPool* ThreadPool::GetInstance() { - std::lock_guard l(threadpool_mu); std::call_once(init_flag_, &ThreadPool::Init); return threadpool_.get(); } -void ThreadPool::TestReset() { - std::lock_guard l(threadpool_mu); - threadpool_.reset(nullptr); - ThreadPool::Init(); -} - void ThreadPool::Init() { if (threadpool_.get() == nullptr) { // TODO(Yancey1989): specify the max threads number diff --git a/paddle/fluid/framework/threadpool.h b/paddle/fluid/framework/threadpool.h index 1513e35bb53d51e636e44937c181f26a36504e0a..0687e628aaa4fb7b2e67938fa09a319c8bb35aff 100644 --- a/paddle/fluid/framework/threadpool.h +++ b/paddle/fluid/framework/threadpool.h @@ -55,10 +55,6 @@ class ThreadPool { // Returns the singleton of ThreadPool. static ThreadPool* GetInstance(); - // delete current thread pool and create a new one. - // Only used by test cases to reset the threadpool. - static void TestReset(); - ~ThreadPool(); // Run pushes a function to the task queue and returns a std::future diff --git a/paddle/fluid/framework/threadpool_test.cc b/paddle/fluid/framework/threadpool_test.cc index cad45d501a9c4a5e4577b63bd7b37889fe457a77..281d3812f8100c3feeebdc8af557576d5539559b 100644 --- a/paddle/fluid/framework/threadpool_test.cc +++ b/paddle/fluid/framework/threadpool_test.cc @@ -52,6 +52,5 @@ TEST(ThreadPool, ConcurrentRun) { for (auto& t : threads) { t.join(); } - framework::ThreadPool::TestReset(); EXPECT_EQ(sum, ((n + 1) * n) / 2); }