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 /src/cpp | |
parent | 6baa9b67ada4f0abadd27a830778463f3e8aabd3 (diff) | |
parent | 700bdeb6f549ed79d586f962b8347b9a5275d5c8 (diff) |
resolve merge confict
Diffstat (limited to 'src/cpp')
-rw-r--r-- | src/cpp/common/completion_queue.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc index 414966c1cd..fede2da016 100644 --- a/src/cpp/common/completion_queue.cc +++ b/src/cpp/common/completion_queue.cc @@ -57,19 +57,26 @@ class EventDeleter { } }; -bool CompletionQueue::Next(void** tag, bool* ok) { +CompletionQueue::NextStatus +CompletionQueue::AsyncNext(void** tag, bool* ok, + std::chrono::system_clock::time_point deadline) { std::unique_ptr<grpc_event, EventDeleter> ev; + gpr_timespec gpr_deadline; + Timepoint2Timespec(deadline, &gpr_deadline); for (;;) { - ev.reset(grpc_completion_queue_next(cq_, gpr_inf_future)); + ev.reset(grpc_completion_queue_next(cq_, gpr_deadline)); + if (!ev) { /* got a NULL back because deadline passed */ + return TIMEOUT; + } if (ev->type == GRPC_QUEUE_SHUTDOWN) { - return false; + return SHUTDOWN; } auto cq_tag = static_cast<CompletionQueueTag*>(ev->tag); *ok = ev->data.op_complete == GRPC_OP_OK; *tag = cq_tag; if (cq_tag->FinalizeResult(tag, ok)) { - return true; + return GOT_EVENT; } } } |