diff options
author | 2017-10-25 10:28:02 -0700 | |
---|---|---|
committer | 2017-10-25 10:28:02 -0700 | |
commit | 1bf7207852b4138c8a30e5a2f8f2c4bfffbba262 (patch) | |
tree | a49ce2246b55aa230802c909898a20d136f3561d /src/cpp | |
parent | 1bda5106421c5e6f449e6dbdd2214cdf31b26fcf (diff) | |
parent | 42bd87e376913939850bfa78a3c7f96ce83af11e (diff) |
Merge pull request #13084 from kpayson64/cq_lambda
CompletionQueue DoThenAsyncNext
Diffstat (limited to 'src/cpp')
-rw-r--r-- | src/cpp/common/completion_queue_cc.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc index f34b0f3d58..4a2e2be688 100644 --- a/src/cpp/common/completion_queue_cc.cc +++ b/src/cpp/common/completion_queue_cc.cc @@ -71,4 +71,29 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( } } +CompletionQueue::CompletionQueueTLSCache::CompletionQueueTLSCache( + CompletionQueue* cq) + : cq_(cq), flushed_(false) { + grpc_completion_queue_thread_local_cache_init(cq_->cq_); +} + +CompletionQueue::CompletionQueueTLSCache::~CompletionQueueTLSCache() { + GPR_ASSERT(flushed_); +} + +bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) { + int res = 0; + void* res_tag; + flushed_ = true; + if (grpc_completion_queue_thread_local_cache_flush(cq_->cq_, &res_tag, + &res)) { + auto cq_tag = static_cast<CompletionQueueTag*>(res_tag); + *ok = res == 1; + if (cq_tag->FinalizeResult(tag, ok)) { + return true; + } + } + return false; +} + } // namespace grpc |