diff --git a/include/grpc++/fixed_size_thread_pool.h b/include/grpc++/fixed_size_thread_pool.h index 9f0cbfbae978425d0378f5c27015d887b6aacf10..bf67cce7b1b89a28caf1ea37ec8afd8e427cf7ea 100644 --- a/include/grpc++/fixed_size_thread_pool.h +++ b/include/grpc++/fixed_size_thread_pool.h @@ -50,7 +50,7 @@ class FixedSizeThreadPool GRPC_FINAL : public ThreadPoolInterface { explicit FixedSizeThreadPool(int num_threads); ~FixedSizeThreadPool(); - void ScheduleCallback(const std::function<void()>& callback) GRPC_OVERRIDE; + void Add(const std::function<void()>& callback) GRPC_OVERRIDE; private: grpc::mutex mu_; diff --git a/include/grpc++/thread_pool_interface.h b/include/grpc++/thread_pool_interface.h index ac4458d5303e746b557f54b93363d6a6a35a8fe6..d080b31dcc550ccc30b00e20b73bee2d9bcedd7c 100644 --- a/include/grpc++/thread_pool_interface.h +++ b/include/grpc++/thread_pool_interface.h @@ -44,7 +44,7 @@ class ThreadPoolInterface { virtual ~ThreadPoolInterface() {} // Schedule the given callback for execution. - virtual void ScheduleCallback(const std::function<void()>& callback) = 0; + virtual void Add(const std::function<void()>& callback) = 0; }; ThreadPoolInterface* CreateDefaultThreadPool(); diff --git a/src/cpp/server/fixed_size_thread_pool.cc b/src/cpp/server/fixed_size_thread_pool.cc index 710bcbb57373475aae51b5500282156bae6c7ff4..bafbc5802a47a9fed72a3e2ccb6a5e3a1d0ed97d 100644 --- a/src/cpp/server/fixed_size_thread_pool.cc +++ b/src/cpp/server/fixed_size_thread_pool.cc @@ -76,8 +76,7 @@ FixedSizeThreadPool::~FixedSizeThreadPool() { } } -void FixedSizeThreadPool::ScheduleCallback( - const std::function<void()>& callback) { +void FixedSizeThreadPool::Add(const std::function<void()>& callback) { grpc::lock_guard<grpc::mutex> lock(mu_); callbacks_.push(callback); cv_.notify_one(); diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index e6761d6244257df31f814de08b0449bbadd591fd..ab87b22f5fbe6a5094c980f30a2a2a5b5eff0671 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -383,7 +383,7 @@ void Server::ScheduleCallback() { grpc::unique_lock<grpc::mutex> lock(mu_); num_running_cb_++; } - thread_pool_->ScheduleCallback(std::bind(&Server::RunRpc, this)); + thread_pool_->Add(std::bind(&Server::RunRpc, this)); } void Server::RunRpc() { diff --git a/test/cpp/server/fixed_size_thread_pool_test.cc b/test/cpp/server/fixed_size_thread_pool_test.cc index d62f4e813230c58c6995140333f10d3f6abb582d..442e974fc154d4a824aa37dd02ef3131b27a4912 100644 --- a/test/cpp/server/fixed_size_thread_pool_test.cc +++ b/test/cpp/server/fixed_size_thread_pool_test.cc @@ -54,12 +54,12 @@ void Callback(std::mutex* mu, std::condition_variable* cv, bool* done) { cv->notify_all(); } -TEST_F(FixedSizeThreadPoolTest, ScheduleCallback) { +TEST_F(FixedSizeThreadPoolTest, Add) { std::mutex mu; std::condition_variable cv; bool done = false; std::function<void()> callback = std::bind(Callback, &mu, &cv, &done); - thread_pool_.ScheduleCallback(callback); + thread_pool_.Add(callback); // Wait for the callback to finish. std::unique_lock<std::mutex> lock(mu);