aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Bogdan Drutu <bdrutu@google.com>2015-12-11 19:48:19 -0800
committerGravatar Bogdan Drutu <bdrutu@google.com>2015-12-11 19:48:19 -0800
commit42ab3fa5fa1c6ab93110b32bb2bd88a8a2bf631e (patch)
treea32e288d9cd5217097b901adb9d4fd53b9bb1a55
parent38d2ad6e96b5fc2f7ee3ae7e82b81983afe50874 (diff)
Add a destructor callback as well
-rw-r--r--include/grpc++/client_context.h3
-rw-r--r--src/cpp/client/client_context.cc2
2 files changed, 4 insertions, 1 deletions
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h
index d3f23fe047..8e7c3579e3 100644
--- a/include/grpc++/client_context.h
+++ b/include/grpc++/client_context.h
@@ -283,10 +283,11 @@ class ClientContext {
/// Global Callbacks
///
/// Can be set exactly once per application to install hooks whenever
- /// a client context is constructed.
+ /// a client context is constructed and destructed.
class GlobalCallbacks {
public:
virtual void DefaultConstructor(ClientContext* context) = 0;
+ virtual void Destructor(ClientContext* context) = 0;
};
static void SetGlobalCallbacks(GlobalCallbacks* callbacks);
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index f33c1e3a9f..a4fdfcb0de 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -48,6 +48,7 @@ namespace grpc {
class DefaultGlobalCallbacks GRPC_FINAL : public ClientContext::GlobalCallbacks {
public:
void DefaultConstructor(ClientContext* context) GRPC_OVERRIDE {}
+ void Destructor(ClientContext* context) GRPC_OVERRIDE {}
};
static DefaultGlobalCallbacks g_default_callbacks;
@@ -66,6 +67,7 @@ ClientContext::~ClientContext() {
if (call_) {
grpc_call_destroy(call_);
}
+ g_callbacks->Destructor(this);
}
std::unique_ptr<ClientContext> ClientContext::FromServerContext(