Skip to content
Snippets Groups Projects
Commit 72a44178 authored by vjpai's avatar vjpai
Browse files

ThreadPoolInterface::ScheduleCallback --> ThreadPoolInterface::Add

parent 65ef0fff
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment