diff options
author | Yang Gao <yangg@google.com> | 2015-03-17 15:47:47 -0700 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2015-03-17 15:47:47 -0700 |
commit | d672d8fbe22e414ca6fee0f279c4550ea927988c (patch) | |
tree | 304a09f6898d9f3f952b057ca3ecd8949615e8dd /include/grpc++/completion_queue.h | |
parent | 6baa9b67ada4f0abadd27a830778463f3e8aabd3 (diff) | |
parent | 700bdeb6f549ed79d586f962b8347b9a5275d5c8 (diff) |
resolve merge confict
Diffstat (limited to 'include/grpc++/completion_queue.h')
-rw-r--r-- | include/grpc++/completion_queue.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 1caaa8d6cf..8a36b09a7f 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -34,6 +34,7 @@ #ifndef GRPCXX_COMPLETION_QUEUE_H #define GRPCXX_COMPLETION_QUEUE_H +#include <chrono> #include <grpc++/impl/client_unary_call.h> struct grpc_completion_queue; @@ -75,10 +76,21 @@ class CompletionQueue { explicit CompletionQueue(grpc_completion_queue* take); ~CompletionQueue(); - // Blocking read from queue. - // Returns true if an event was received, false if the queue is ready - // for destruction. - bool Next(void** tag, bool* ok); + // Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT + enum NextStatus {SHUTDOWN, GOT_EVENT, TIMEOUT}; + + // Nonblocking (until deadline) read from queue. + // Cannot rely on result of tag or ok if return is TIMEOUT + NextStatus AsyncNext(void **tag, bool *ok, + std::chrono::system_clock::time_point deadline); + + // Blocking (until deadline) read from queue. + // Returns false if the queue is ready for destruction, true if event + bool Next(void **tag, bool *ok) { + return (AsyncNext(tag,ok, + std::chrono::system_clock::time_point::max()) != + SHUTDOWN); + } // Shutdown has to be called, and the CompletionQueue can only be // destructed when false is returned from Next(). |