From 64e7688ade5dd817a51f5ca2d4d7229313c82769 Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Thu, 25 Oct 2018 13:40:03 +0800 Subject: [PATCH] clean more APIs test=develop --- paddle/fluid/framework/threadpool.cc | 8 -------- paddle/fluid/framework/threadpool.h | 4 ---- paddle/fluid/framework/threadpool_test.cc | 1 - 3 files changed, 13 deletions(-) diff --git a/paddle/fluid/framework/threadpool.cc b/paddle/fluid/framework/threadpool.cc index 3041fbe5a84..a588cb417ae 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 1513e35bb53..0687e628aaa 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 cad45d501a9..281d3812f81 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); } -- GitLab