diff options
author | 2018-08-29 11:20:16 -0700 | |
---|---|---|
committer | 2018-08-30 15:46:27 -0700 | |
commit | 6b6bdbbb769776430a2f8aa782f1141b7eea91ad (patch) | |
tree | 4fa516ebbb42e6230326065eb2569671a33a9590 /src/cpp/client/channel_cc.cc | |
parent | ccddc1bd177ff2ff6ff7500e1cd66e2be409614c (diff) |
Address reviewer and clang-tidy comments
Diffstat (limited to 'src/cpp/client/channel_cc.cc')
-rw-r--r-- | src/cpp/client/channel_cc.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index 2a961e6e27..ad71286e05 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -195,7 +195,12 @@ bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed, namespace { class ShutdownCallback : public grpc_core::CQCallbackInterface { public: + // TakeCQ takes ownership of the cq into the shutdown callback + // so that the shutdown callback will be responsible for destroying it void TakeCQ(CompletionQueue* cq) { cq_ = cq; } + + // The Run function will get invoked by the completion queue library + // when the shutdown is actually complete void Run(bool) override { delete cq_; grpc_core::Delete(this); @@ -215,6 +220,8 @@ CompletionQueue* Channel::CallbackCQ() { callback_cq_ = new CompletionQueue(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, shutdown_callback}); + + // Transfer ownership of the new cq to its own shutdown callback shutdown_callback->TakeCQ(callback_cq_); } return callback_cq_; |