diff options
author | Sree Kuchibhotla <sreek@google.com> | 2016-12-09 22:42:54 -0800 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2016-12-09 22:42:54 -0800 |
commit | e33daabb8806de494bcaa9adf201025dadf5d102 (patch) | |
tree | 9fcf80078db52fca0bfff84618042414f4f8d4cc /src/cpp/common/completion_queue_cc.cc | |
parent | 762ce2744c4c3814d537705e8fdfb54f4a64f26a (diff) | |
parent | 48b1558823355016ffc852ca6b97d6b39f4c04eb (diff) |
Merge branch 'master' into reduce_cq
Diffstat (limited to 'src/cpp/common/completion_queue_cc.cc')
-rw-r--r-- | src/cpp/common/completion_queue_cc.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc index 00cc102f92..0408a41085 100644 --- a/src/cpp/common/completion_queue_cc.cc +++ b/src/cpp/common/completion_queue_cc.cc @@ -43,11 +43,21 @@ namespace grpc { static internal::GrpcLibraryInitializer g_gli_initializer; -CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) {} +CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) { + InitialAvalanching(); +} void CompletionQueue::Shutdown() { g_gli_initializer.summon(); - grpc_completion_queue_shutdown(cq_); + CompleteAvalanching(); +} + +void CompletionQueue::CompleteAvalanching() { + // Check if this was the last avalanching operation + if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast<gpr_atm>(-1)) == 1) { + grpc_completion_queue_shutdown(cq_); + } } CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( |