Skip to content

Commit

Permalink
Add a destructor callback as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Drutu committed Dec 12, 2015
1 parent 38d2ad6 commit 42ab3fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/grpc++/client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/cpp/client/client_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -66,6 +67,7 @@ ClientContext::~ClientContext() {
if (call_) {
grpc_call_destroy(call_);
}
g_callbacks->Destructor(this);
}

std::unique_ptr<ClientContext> ClientContext::FromServerContext(
Expand Down

0 comments on commit 42ab3fa

Please sign in to comment.