Skip to content

Commit

Permalink
Revert "Use typedefs to avoid triply-nested function templates"
Browse files Browse the repository at this point in the history
This reverts commit 45b0bc4.

This revert is being done because the compilers on Travis don't
understand the C++11 template/using syntax.
  • Loading branch information
vjpai committed Feb 28, 2015
1 parent 45b0bc4 commit 4e1e1bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
19 changes: 6 additions & 13 deletions test/cpp/qps/client_async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,17 @@ class ClientRpcContext {
}
virtual void report_stats(gpr_histogram *hist) = 0;
};

template <class RequestType, class ResponseType>
using StartMethod = std::function<
std::unique_ptr<grpc::ClientAsyncResponseReader
<ResponseType>>(TestService::Stub *, grpc::ClientContext *,
const RequestType &, void *)> ;

template <class ResponseType> using DoneMethod =
std::function<void(grpc::Status, ResponseType *)>;

template <class RequestType, class ResponseType>
class ClientRpcContextUnaryImpl : public ClientRpcContext {
public:
ClientRpcContextUnaryImpl(
TestService::Stub *stub,
const RequestType &req,
StartMethod<RequestType,ResponseType> start_req,
DoneMethod<ResponseType> on_done)
std::function<
std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>(
TestService::Stub *, grpc::ClientContext *, const RequestType &,
void *)> start_req,
std::function<void(grpc::Status, ResponseType *)> on_done)
: context_(),
stub_(stub),
req_(req),
Expand Down Expand Up @@ -157,7 +150,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
RequestType req_;
ResponseType response_;
bool (ClientRpcContextUnaryImpl::*next_state_)();
DoneMethod<ResponseType> callback_;
std::function<void(grpc::Status, ResponseType *)> callback_;
grpc::Status status_;
double start_;
std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>
Expand Down
29 changes: 16 additions & 13 deletions test/cpp/qps/server_async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,15 @@ class AsyncQpsServerTest {
return reinterpret_cast<ServerRpcContext *>(tag);
}

template<class RequestType, class ResponseType>
using RequestMethod = std::function<void(ServerContext *, RequestType *,
grpc::ServerAsyncResponseWriter<ResponseType> *,
void *)>;
template<class RequestType, class ResponseType> using InvokeMethod =
std::function<grpc::Status(const RequestType *, ResponseType *)>;

template <class RequestType, class ResponseType>
class ServerRpcContextUnaryImpl : public ServerRpcContext {
public:
ServerRpcContextUnaryImpl(
RequestMethod<RequestType,ResponseType> request_method,
InvokeMethod<RequestType,ResponseType> invoke_method)
std::function<void(ServerContext *, RequestType *,
grpc::ServerAsyncResponseWriter<ResponseType> *,
void *)> request_method,
std::function<grpc::Status(const RequestType *, ResponseType *)>
invoke_method)
: next_state_(&ServerRpcContextUnaryImpl::invoker),
request_method_(request_method),
invoke_method_(invoke_method),
Expand Down Expand Up @@ -233,8 +229,11 @@ class AsyncQpsServerTest {
ServerContext srv_ctx_;
RequestType req_;
bool (ServerRpcContextUnaryImpl::*next_state_)();
RequestMethod<RequestType,ResponseType> request_method_;
InvokeMethod<RequestType,ResponseType> invoke_method_;
std::function<void(ServerContext *, RequestType *,
grpc::ServerAsyncResponseWriter<ResponseType> *, void *)>
request_method_;
std::function<grpc::Status(const RequestType *, ResponseType *)>
invoke_method_;
grpc::ServerAsyncResponseWriter<ResponseType> response_writer_;
};

Expand Down Expand Up @@ -262,8 +261,12 @@ class AsyncQpsServerTest {
CompletionQueue srv_cq_;
TestService::AsyncService async_service_;
std::unique_ptr<Server> server_;
RequestMethod<SimpleRequest, SimpleResponse> request_unary_;
RequestMethod<StatsRequest, ServerStats> request_stats_;
std::function<void(ServerContext *, SimpleRequest *,
grpc::ServerAsyncResponseWriter<SimpleResponse> *, void *)>
request_unary_;
std::function<void(ServerContext *, StatsRequest *,
grpc::ServerAsyncResponseWriter<ServerStats> *, void *)>
request_stats_;
std::forward_list<ServerRpcContext *> contexts_;
};

Expand Down

0 comments on commit 4e1e1bc

Please sign in to comment.