diff options
author | 2016-12-06 20:23:13 -0800 | |
---|---|---|
committer | 2016-12-06 20:23:13 -0800 | |
commit | 35769dc29c5fd55ccaf8a234d8704fe7dd7c7fdb (patch) | |
tree | 73ceacb8b27e20b189c8c5736378dff695f950b9 /src/cpp/common/completion_queue_cc.cc | |
parent | ebffb4b8231ee397b9415966a6e76c99099fe3c2 (diff) | |
parent | fede4d4198c5d211b8042d29a6f86ff7cafcf666 (diff) |
Merge branch 'slice_with_exec_ctx' into slice_interning
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( |