diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-02-09 17:15:03 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-02-09 17:15:03 -0800 |
commit | de917062ecacbeb547c8e2e4e3f4260d3e9a2f2e (patch) | |
tree | 20befa87421de79a47afc542554549400e0bd8e6 /include/grpc++/completion_queue.h | |
parent | 7630205bdfe2b7871e810f8ea7eab388d02240bf (diff) |
Refine completion queue
Diffstat (limited to 'include/grpc++/completion_queue.h')
-rw-r--r-- | include/grpc++/completion_queue.h | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 8033fd1205..641d599c7e 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -38,21 +38,27 @@ struct grpc_completion_queue; namespace grpc { +template <class R> +class ClientReader; +template <class W> +class ClientWriter; +template <class R, class W> +class ClientReaderWriter; +template <class R> +class ServerReader; +template <class W> +class ServerWriter; +template <class R, class W> +class ServerReaderWriter; + class CompletionQueue; class CompletionQueueTag { public: - enum FinalizeResultOutput { - SUCCEED, - FAIL, - SWALLOW, - }; - - virtual FinalizeResultOutput FinalizeResult(bool status) = 0; - - private: - friend class CompletionQueue; - void *user_tag_; + // Called prior to returning from Next(), return value + // is the status of the operation (return status is the default thing + // to do) + virtual void FinalizeResult(void *tag, bool *status) = 0; }; // grpc_completion_queue wrapper class @@ -66,22 +72,6 @@ class CompletionQueue { // for destruction. bool Next(void **tag, bool *ok); - bool Pluck(void *tag); - - // Prepare a tag for the C api - // Given a tag we'd like to receive from Next, what tag should we pass - // down to the C api? - // Usage example: - // grpc_call_start_batch(..., cq.PrepareTagForC(tag)); - // Allows attaching some work to be executed before the original tag - // is returned. - // MUST be used for all events that could be surfaced through this - // wrapping API - void *PrepareTagForC(CompletionQueueTag *cq_tag, void *user_tag) { - cq_tag->user_tag_ = user_tag; - return cq_tag; - } - // Shutdown has to be called, and the CompletionQueue can only be // destructed when false is returned from Next(). void Shutdown(); @@ -89,6 +79,15 @@ class CompletionQueue { grpc_completion_queue* cq() { return cq_; } private: + template <class R> friend class ::grpc::ClientReader; + template <class W> friend class ::grpc::ClientWriter; + template <class R, class W> friend class ::grpc::ClientReaderWriter; + template <class R> friend class ::grpc::ServerReader; + template <class W> friend class ::grpc::ServerWriter; + template <class R, class W> friend class ::grpc::ServerReaderWriter; + + bool Pluck(CompletionQueueTag *tag); + grpc_completion_queue* cq_; // owned }; |