aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar vjpai <vpai@google.com>2015-07-16 21:44:44 -0700
committerGravatar vjpai <vpai@google.com>2015-07-16 21:44:44 -0700
commit72a44178e92cc103507e2bdc1a52e709de83b767 (patch)
treeae469fd67a5ec288798e80e58e10bcc31a998895
parent65ef0fffaecf8396cb93b3a76416d099f7b07438 (diff)
ThreadPoolInterface::ScheduleCallback --> ThreadPoolInterface::Add
-rw-r--r--include/grpc++/fixed_size_thread_pool.h2
-rw-r--r--include/grpc++/thread_pool_interface.h2
-rw-r--r--src/cpp/server/fixed_size_thread_pool.cc3
-rw-r--r--src/cpp/server/server.cc2
-rw-r--r--test/cpp/server/fixed_size_thread_pool_test.cc4
5 files changed, 6 insertions, 7 deletions
diff --git a/include/grpc++/fixed_size_thread_pool.h b/include/grpc++/fixed_size_thread_pool.h
index 9f0cbfbae9..bf67cce7b1 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 ac4458d530..d080b31dcc 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 710bcbb573..bafbc5802a 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 e6761d6244..ab87b22f5f 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 d62f4e8132..442e974fc1 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);