diff options
author | 2015-02-09 14:56:49 -0800 | |
---|---|---|
committer | 2015-02-09 14:56:49 -0800 | |
commit | 061754a483a1b56fe24649ae2be68ffa613a643f (patch) | |
tree | c631fb60b4f218e14f396803dd693cfe66e7fa16 /src/cpp/common | |
parent | 1801e420de7c2e2dce8876aade7b9f010c0e0002 (diff) |
Cleanup some cruft
Diffstat (limited to 'src/cpp/common')
-rw-r--r-- | src/cpp/common/completion_queue.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc index 55adb5bea5..31c1fb9286 100644 --- a/src/cpp/common/completion_queue.cc +++ b/src/cpp/common/completion_queue.cc @@ -57,15 +57,19 @@ class EventDeleter { bool CompletionQueue::Next(void **tag, bool *ok) { std::unique_ptr<grpc_event, EventDeleter> ev; - ev.reset(grpc_completion_queue_next(cq_, gpr_inf_future)); - if (ev->type == GRPC_QUEUE_SHUTDOWN) { - return false; + while (true) { + ev.reset(grpc_completion_queue_next(cq_, gpr_inf_future)); + if (ev->type == GRPC_QUEUE_SHUTDOWN) { + return false; + } + auto cq_tag = static_cast<CompletionQueueTag *>(ev->tag); + switch (cq_tag->FinalizeResult(ev->data.op_complete == GRPC_OP_OK)) { + case CompletionQueueTag::SUCCEED: *ok = true; break; + case CompletionQueueTag::FAIL: *ok = false; break; + case CompletionQueueTag::SWALLOW: continue; + } + return true; } - auto cq_tag = static_cast<CompletionQueueTag *>(ev->tag); - cq_tag->FinalizeResult(); - *tag = cq_tag->user_tag_; - *ok = ev->data.op_complete == GRPC_OP_OK; - return true; } } // namespace grpc |