diff --git a/cpp/helloworld/greeter_async_client.cc b/cpp/helloworld/greeter_async_client.cc index 5fa6ec6edbf..b131005ef3a 100644 --- a/cpp/helloworld/greeter_async_client.cc +++ b/cpp/helloworld/greeter_async_client.cc @@ -90,22 +90,16 @@ class GreeterClient { } } - void Shutdown() { stub_.reset(); } - private: std::unique_ptr stub_; }; int main(int argc, char** argv) { - grpc_init(); - GreeterClient greeter(grpc::CreateChannel( "localhost:50051", grpc::InsecureCredentials(), ChannelArguments())); std::string user("world"); std::string reply = greeter.SayHello(user); std::cout << "Greeter received: " << reply << std::endl; - greeter.Shutdown(); - - grpc_shutdown(); + return 0; } diff --git a/cpp/helloworld/greeter_async_server.cc b/cpp/helloworld/greeter_async_server.cc index 47110a719f7..2e5343b364a 100644 --- a/cpp/helloworld/greeter_async_server.cc +++ b/cpp/helloworld/greeter_async_server.cc @@ -131,11 +131,8 @@ class ServerImpl final { }; int main(int argc, char** argv) { - grpc_init(); - ServerImpl server; server.Run(); - grpc_shutdown(); return 0; } diff --git a/cpp/helloworld/greeter_client.cc b/cpp/helloworld/greeter_client.cc index 4776cf9d3d0..c0aec1696a4 100644 --- a/cpp/helloworld/greeter_client.cc +++ b/cpp/helloworld/greeter_client.cc @@ -71,15 +71,11 @@ class GreeterClient { } } - void Shutdown() { stub_.reset(); } - private: std::unique_ptr stub_; }; int main(int argc, char** argv) { - grpc_init(); - GreeterClient greeter( grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials(), ChannelArguments())); @@ -87,7 +83,5 @@ int main(int argc, char** argv) { std::string reply = greeter.SayHello(user); std::cout << "Greeter received: " << reply << std::endl; - greeter.Shutdown(); - - grpc_shutdown(); + return 0; } diff --git a/cpp/helloworld/greeter_server.cc b/cpp/helloworld/greeter_server.cc index a090075d9f2..e40bf1b3a1a 100644 --- a/cpp/helloworld/greeter_server.cc +++ b/cpp/helloworld/greeter_server.cc @@ -73,10 +73,7 @@ void RunServer() { } int main(int argc, char** argv) { - grpc_init(); - RunServer(); - grpc_shutdown(); return 0; } diff --git a/cpp/route_guide/route_guide_client.cc b/cpp/route_guide/route_guide_client.cc index e2b7d5a58e9..91e1cebfc7a 100644 --- a/cpp/route_guide/route_guide_client.cc +++ b/cpp/route_guide/route_guide_client.cc @@ -205,8 +205,6 @@ class RouteGuideClient { } } - void Shutdown() { stub_.reset(); } - private: bool GetOneFeature(const Point& point, Feature* feature) { @@ -238,8 +236,6 @@ class RouteGuideClient { }; int main(int argc, char** argv) { - grpc_init(); - // Expect only arg: --db_path=path/to/route_guide_db.json. std::string db = examples::GetDbFileContent(argc, argv); RouteGuideClient guide( @@ -256,7 +252,5 @@ int main(int argc, char** argv) { std::cout << "-------------- RouteChat --------------" << std::endl; guide.RouteChat(); - guide.Shutdown(); - - grpc_shutdown(); + return 0; } diff --git a/cpp/route_guide/route_guide_server.cc b/cpp/route_guide/route_guide_server.cc index 417f7815351..8a0ea26132a 100644 --- a/cpp/route_guide/route_guide_server.cc +++ b/cpp/route_guide/route_guide_server.cc @@ -111,7 +111,8 @@ class RouteGuideImpl final : public RouteGuide::Service { return Status::OK; } - Status ListFeatures(ServerContext* context, const examples::Rectangle* rectangle, + Status ListFeatures(ServerContext* context, + const examples::Rectangle* rectangle, ServerWriter* writer) override { auto lo = rectangle->lo(); auto hi = rectangle->hi(); @@ -195,12 +196,9 @@ void RunServer(const std::string& db_path) { } int main(int argc, char** argv) { - grpc_init(); - // Expect only arg: --db_path=path/to/route_guide_db.json. std::string db = examples::GetDbFileContent(argc, argv); RunServer(db); - grpc_shutdown(); return 0; }