Merge pull request #2482 from vjpai/rename_schedule_callback

ThreadPoolInterface::ScheduleCallback --> ThreadPoolInterface::Add
pull/2319/head^2
Craig Tiller 10 years ago
commit 29cb6dd21f
  1. 2
      include/grpc++/fixed_size_thread_pool.h
  2. 2
      include/grpc++/thread_pool_interface.h
  3. 3
      src/cpp/server/fixed_size_thread_pool.cc
  4. 2
      src/cpp/server/server.cc
  5. 4
      test/cpp/server/fixed_size_thread_pool_test.cc

@ -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_;

@ -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();

@ -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();

@ -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() {

@ -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);

Loading…
Cancel
Save