Rename Async methods from generator to avoid naming conflicts to
bind and other functions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 8910323..7710df6 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -186,7 +186,7 @@
printer->Print(
*vars,
"std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> "
- "$Method$(::grpc::ClientContext* context, "
+ "Async$Method$(::grpc::ClientContext* context, "
"const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag);\n");
} else if (ClientOnlyStreaming(method)) {
@@ -196,7 +196,7 @@
"::grpc::ClientContext* context, $Response$* response);\n");
printer->Print(
*vars,
- "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>> $Method$("
+ "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>> Async$Method$("
"::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq, void* tag);\n");
} else if (ServerOnlyStreaming(method)) {
@@ -206,7 +206,7 @@
"::grpc::ClientContext* context, const $Request$& request);\n");
printer->Print(
*vars,
- "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> $Method$("
+ "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> Async$Method$("
"::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag);\n");
} else if (BidiStreaming(method)) {
@@ -217,7 +217,7 @@
printer->Print(*vars,
"std::unique_ptr< ::grpc::ClientAsyncReaderWriter< "
"$Request$, $Response$>> "
- "$Method$(::grpc::ClientContext* context, "
+ "Async$Method$(::grpc::ClientContext* context, "
"::grpc::CompletionQueue* cq, void* tag);\n");
}
}
@@ -390,7 +390,7 @@
printer->Print(
*vars,
"std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> "
- "$Service$::Stub::$Method$(::grpc::ClientContext* context, "
+ "$Service$::Stub::Async$Method$(::grpc::ClientContext* context, "
"const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
@@ -416,7 +416,7 @@
"}\n\n");
printer->Print(*vars,
"std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>> "
- "$Service$::Stub::$Method$("
+ "$Service$::Stub::Async$Method$("
"::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
@@ -443,7 +443,7 @@
"}\n\n");
printer->Print(*vars,
"std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> "
- "$Service$::Stub::$Method$("
+ "$Service$::Stub::Async$Method$("
"::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
@@ -471,7 +471,7 @@
printer->Print(*vars,
"std::unique_ptr< ::grpc::ClientAsyncReaderWriter< "
"$Request$, $Response$>> "
- "$Service$::Stub::$Method$(::grpc::ClientContext* context, "
+ "$Service$::Stub::Async$Method$(::grpc::ClientContext* context, "
"::grpc::CompletionQueue* cq, void* tag) {\n");
printer->Print(*vars,
" return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< "
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 9e25a53..7698e86 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -136,7 +136,7 @@
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> >
- response_reader(stub_->Echo(
+ response_reader(stub_->AsyncEcho(
&cli_ctx, send_request, &cli_cq_, tag(1)));
service_.RequestEcho(
@@ -191,7 +191,7 @@
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncWriter<EchoRequest> > cli_stream(
- stub_->RequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1)));
+ stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1)));
service_.RequestRequestStream(
&srv_ctx, &srv_stream, &srv_cq_, tag(2));
@@ -245,7 +245,7 @@
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncReader<EchoResponse> > cli_stream(
- stub_->ResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1)));
+ stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1)));
service_.RequestResponseStream(
&srv_ctx, &recv_request, &srv_stream, &srv_cq_, tag(2));
@@ -296,7 +296,7 @@
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse> >
- cli_stream(stub_->BidiStream(&cli_ctx, &cli_cq_, tag(1)));
+ cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1)));
service_.RequestBidiStream(
&srv_ctx, &srv_stream, &srv_cq_, tag(2));
@@ -355,7 +355,7 @@
cli_ctx.AddMetadata(meta2.first, meta2.second);
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
+ stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1)));
service_.RequestEcho(
&srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
@@ -397,7 +397,7 @@
std::pair<grpc::string, grpc::string> meta2("key2", "val2");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
+ stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1)));
service_.RequestEcho(
&srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
@@ -445,7 +445,7 @@
std::pair<grpc::string, grpc::string> meta2("key2", "val2");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
+ stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1)));
service_.RequestEcho(
&srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
@@ -501,7 +501,7 @@
cli_ctx.AddMetadata(meta2.first, meta2.second);
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1)));
+ stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1)));
service_.RequestEcho(
&srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2));
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index 13db4fe..4034491 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -109,9 +109,9 @@
class ClientRpcContextUnaryImpl : public ClientRpcContext {
public:
ClientRpcContextUnaryImpl(const RequestType& req,
- std::function<grpc::ClientAsyncResponseReader<
- ResponseType> *(grpc::ClientContext *,
- const RequestType&, void *)> start_req,
+ std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<
+ ResponseType>>(grpc::ClientContext *,
+ const RequestType&, void *)> start_req,
std::function<void(grpc::Status, ResponseType *)> on_done):
context_(), req_(req), response_(),
next_state_(&ClientRpcContextUnaryImpl::ReqSent),
@@ -226,8 +226,7 @@
TestService::Stub *stub =
channels[channel_num].get_stub();
grpc::ClientContext context;
- auto start_req = std::bind(static_cast<grpc::ClientAsyncResponseReader<SimpleResponse>*(TestService::Stub::*)(grpc::ClientContext *,const SimpleRequest &,grpc::CompletionQueue *,void *)>
- (&TestService::Stub::UnaryCall),
+ auto start_req = std::bind(&TestService::Stub::AsyncUnaryCall,
stub, _1, _2, &cli_cq, _3);
new ClientRpcContextUnaryImpl<SimpleRequest,
SimpleResponse>(request,