Address code review comments

pull/8269/head
Sree Kuchibhotla 8 years ago
parent 556aebb1e0
commit 385c9b2f05
  1. 2
      include/grpc++/server.h
  2. 2
      include/grpc++/server_builder.h
  3. 5
      src/cpp/server/server_builder.cc
  4. 5
      src/cpp/server/server_cc.cc
  5. 5
      src/cpp/thread_manager/thread_manager.cc
  6. 2
      src/cpp/thread_manager/thread_manager.h
  7. 6
      test/cpp/thread_manager/thread_manager_test.cc

@ -212,7 +212,7 @@ class Server GRPC_FINAL : public ServerInterface, private GrpcLibraryCodegen {
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_;

@ -217,7 +217,7 @@ class ServerBuilder {
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_;

@ -116,7 +116,6 @@ ServerBuilder& ServerBuilder::SetSyncServerOption(
case NUM_CQS:
sync_server_settings_.num_cqs = val;
break;
case MIN_POLLERS:
sync_server_settings_.min_pollers = val;
break;
@ -217,8 +216,8 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
// 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

@ -312,10 +312,7 @@ class Server::SyncRequestThreadManager : public ThreadManager {
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);
}
}

@ -42,7 +42,7 @@ namespace grpc {
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 @@ void ThreadManager::WorkerThread::Run() {
}
ThreadManager::WorkerThread::~WorkerThread() {
thd_->join();
thd_.reset();
thd_.join();
}
ThreadManager::ThreadManager(int min_pollers, int max_pollers)

@ -114,7 +114,7 @@ class ThreadManager {
void Run();
ThreadManager* thd_mgr_;
std::unique_ptr<grpc::thread> thd_;
grpc::thread thd_;
};
// The main funtion in ThreadManager

@ -85,8 +85,10 @@ void ThreadManagerTest::DoWork(void *tag, bool ok) {
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) {

Loading…
Cancel
Save