Address code review comments
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index d0a357a..fb04b88 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -212,7 +212,7 @@
std::vector<grpc::string> services_;
bool has_generic_service_;
- // Pointer to the c core's grpc server.
+ // Pointer to the wrapped grpc_server.
grpc_server* server_;
std::unique_ptr<ServerInitializer> server_initializer_;
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index 607df74..c6bcf8b 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -217,7 +217,7 @@
SyncServerSettings sync_server_settings_;
- /* List of completion queues added via AddCompletionQueue() method */
+ // List of completion queues added via AddCompletionQueue() method
std::vector<ServerCompletionQueue*> cqs_;
std::shared_ptr<ServerCredentials> creds_;
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index f4e7733..9bf3221 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -116,7 +116,6 @@
case NUM_CQS:
sync_server_settings_.num_cqs = val;
break;
-
case MIN_POLLERS:
sync_server_settings_.min_pollers = val;
break;
@@ -217,8 +216,8 @@
// ServerBuilder's AddCompletionQueue() method (those completion queues
// are in 'cqs_' member variable of ServerBuilder object)
std::shared_ptr<std::vector<std::unique_ptr<ServerCompletionQueue>>>
- sync_server_cqs(
- new std::vector<std::unique_ptr<ServerCompletionQueue>>());
+ sync_server_cqs = std::make_shared<
+ std::vector<std::unique_ptr<ServerCompletionQueue>>>();
if (has_sync_methods) {
// This is a Sync server
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index da7de13..809e74c 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -312,10 +312,7 @@
if (!sync_methods_.empty()) {
unknown_method_.reset(new RpcServiceMethod(
"unknown", RpcMethod::BIDI_STREAMING, new UnknownMethodHandler));
- // Use of emplace_back with just constructor arguments is not accepted
- // here by gcc-4.4 because it can't match the anonymous nullptr with a
- // proper constructor implicitly. Construct the object and use push_back.
- sync_methods_.push_back(SyncRequest(unknown_method_.get(), nullptr));
+ sync_methods_.emplace_back(unknown_method_.get(), nullptr);
}
}
diff --git a/src/cpp/thread_manager/thread_manager.cc b/src/cpp/thread_manager/thread_manager.cc
index e2b3251..c4bf842 100644
--- a/src/cpp/thread_manager/thread_manager.cc
+++ b/src/cpp/thread_manager/thread_manager.cc
@@ -42,7 +42,7 @@
ThreadManager::WorkerThread::WorkerThread(ThreadManager* thd_mgr)
: thd_mgr_(thd_mgr),
- thd_(new std::thread(&ThreadManager::WorkerThread::Run, this)) {}
+ thd_(&ThreadManager::WorkerThread::Run, this) {}
void ThreadManager::WorkerThread::Run() {
thd_mgr_->MainWorkLoop();
@@ -50,8 +50,7 @@
}
ThreadManager::WorkerThread::~WorkerThread() {
- thd_->join();
- thd_.reset();
+ thd_.join();
}
ThreadManager::ThreadManager(int min_pollers, int max_pollers)
diff --git a/src/cpp/thread_manager/thread_manager.h b/src/cpp/thread_manager/thread_manager.h
index b667a64..1bb13a6 100644
--- a/src/cpp/thread_manager/thread_manager.h
+++ b/src/cpp/thread_manager/thread_manager.h
@@ -114,7 +114,7 @@
void Run();
ThreadManager* thd_mgr_;
- std::unique_ptr<grpc::thread> thd_;
+ grpc::thread thd_;
};
// The main funtion in ThreadManager
diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc
index 990e2ba..9265c29 100644
--- a/test/cpp/thread_manager/thread_manager_test.cc
+++ b/test/cpp/thread_manager/thread_manager_test.cc
@@ -85,8 +85,10 @@
gpr_log(GPR_DEBUG, "DoWork()");
}
- // Simulate "doing work" by sleeping
- std::this_thread::sleep_for(std::chrono::milliseconds(kDoWorkDurationMsec));
+ gpr_timespec sleep_time =
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(kDoWorkDurationMsec, GPR_TIMESPAN));
+ gpr_sleep_until(sleep_time);
}
int main(int argc, char **argv) {