diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-06-04 17:22:54 -0700 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-06-04 17:22:54 -0700 |
commit | 7bc97bc6def1a9d8237e42fe067fbfe64fc2ee43 (patch) | |
tree | f84e9c8bf013da8c02d603d74c002cde1538dbc8 /include/grpc++/server.h | |
parent | 789471cfc64cd0200a53914939a0485846b5a80f (diff) |
Everything compiles again
Diffstat (limited to 'include/grpc++/server.h')
-rw-r--r-- | include/grpc++/server.h | 88 |
1 files changed, 68 insertions, 20 deletions
diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 4784bace1c..a6883e24e6 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -101,40 +101,82 @@ class Server GRPC_FINAL : public GrpcLibrary, class BaseAsyncRequest : public CompletionQueueTag { public: - BaseAsyncRequest(Server* server, - ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag); - - private: + BaseAsyncRequest(Server* server, ServerContext* context, + ServerAsyncStreamingInterface* stream, + CompletionQueue* call_cq, + void* tag); + virtual ~BaseAsyncRequest(); + + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; + + protected: + void FinalizeMetadata(ServerContext* context); + + Server* const server_; + ServerContext* const context_; + ServerAsyncStreamingInterface* const stream_; + CompletionQueue* const call_cq_; + grpc_call* call_; + grpc_metadata_array initial_metadata_array_; }; class RegisteredAsyncRequest : public BaseAsyncRequest { public: RegisteredAsyncRequest(Server* server, ServerContext* context, - ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) - : BaseAsyncRequest(server, stream, call_cq, notification_cq, tag) {} + ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, void* tag); + + // uses BaseAsyncRequest::FinalizeResult + + protected: + void IssueRequest(void* registered_method, grpc_byte_buffer** payload, ServerCompletionQueue *notification_cq); }; - class NoPayloadAsyncRequest : public RegisteredAsyncRequest { + class NoPayloadAsyncRequest GRPC_FINAL : public RegisteredAsyncRequest { public: - NoPayloadAsyncRequest(Server* server, ServerContext* context, + NoPayloadAsyncRequest(void* registered_method, Server* server, ServerContext* context, ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) - : RegisteredAsyncRequest(server, context, stream, call_cq, notification_cq, tag) { + : RegisteredAsyncRequest(server, context, stream, call_cq, tag) { + IssueRequest(registered_method, nullptr, notification_cq); } + + // uses RegisteredAsyncRequest::FinalizeResult }; template <class Message> - class PayloadAsyncRequest : public RegisteredAsyncRequest { - PayloadAsyncRequest(Server* server, ServerContext* context, + class PayloadAsyncRequest GRPC_FINAL : public RegisteredAsyncRequest { + public: + PayloadAsyncRequest(void* registered_method, Server* server, ServerContext* context, ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) - : RegisteredAsyncRequest(server, context, stream, call_cq, notification_cq, tag) { + ServerCompletionQueue* notification_cq, void* tag, Message* request) + : RegisteredAsyncRequest(server, context, stream, call_cq, tag), request_(request) { + IssueRequest(registered_method, &payload_, notification_cq); + } + + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { + bool serialization_status = *status && payload_ && SerializationTraits<Message>::Deserialize(payload_, request_, server_->max_message_size_).IsOk(); + bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status); + *status = serialization_status && *status; + return ret; } + + private: + grpc_byte_buffer* payload_; + Message* const request_; }; - class GenericAsyncRequest : public BaseAsyncRequest { + class GenericAsyncRequest GRPC_FINAL : public BaseAsyncRequest { + public: + GenericAsyncRequest(Server* server, GenericServerContext* context, + ServerAsyncStreamingInterface* stream, + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, + void* tag); + + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; + + private: + grpc_call_details call_details_; }; template <class Message> @@ -142,19 +184,25 @@ class Server GRPC_FINAL : public GrpcLibrary, ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, - void* tag, Message *message); + void* tag, Message *message) { + new PayloadAsyncRequest<Message>(registered_method, this, context, stream, call_cq, notification_cq, tag, message); + } void RequestAsyncCall(void* registered_method, ServerContext* context, ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, - void* tag); + void* tag) { + new NoPayloadAsyncRequest(registered_method, this, context, stream, call_cq, notification_cq, tag); + } void RequestAsyncGenericCall(GenericServerContext* context, ServerAsyncStreamingInterface* stream, - CompletionQueue* cq, + CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, - void* tag); + void* tag) { + new GenericAsyncRequest(this, context, stream, call_cq, notification_cq, tag); + } const int max_message_size_; |