diff options
author | Vijay Pai <vpai@google.com> | 2018-08-30 17:21:07 -0700 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2018-08-31 10:11:38 -0700 |
commit | 5474e92292a37ea9017db02da1e8e6aea621b156 (patch) | |
tree | df57fcffedd27789a438d95d5296001392987c16 /include/grpcpp/impl/codegen/callback_common.h | |
parent | d4afae9a56ff0f5b9b3cda380c0b9c64be170f87 (diff) |
Allocate using call arenas
Diffstat (limited to 'include/grpcpp/impl/codegen/callback_common.h')
-rw-r--r-- | include/grpcpp/impl/codegen/callback_common.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/include/grpcpp/impl/codegen/callback_common.h b/include/grpcpp/impl/codegen/callback_common.h index b14ed0c24f..3481460c76 100644 --- a/include/grpcpp/impl/codegen/callback_common.h +++ b/include/grpcpp/impl/codegen/callback_common.h @@ -37,11 +37,14 @@ namespace internal { class CallbackWithStatusTag { public: - // TODO(vjpai): make impl and ops part of this structure to avoid allocation, - // ownership transfer, and delete - CallbackWithStatusTag(std::function<void(Status)> f, bool self_delete, + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(CallbackWithStatusTag)); + } + + CallbackWithStatusTag(grpc_call* call, std::function<void(Status)> f, CompletionQueueTag* ops); - ~CallbackWithStatusTag() { delete ops_; } + ~CallbackWithStatusTag() {} void* tag() { return static_cast<void*>(impl_); } Status* status_ptr() { return status_; } CompletionQueueTag* ops() { return ops_; } @@ -57,11 +60,14 @@ class CallbackWithStatusTag { class CallbackWithSuccessTag { public: - // TODO(vjpai): make impl and ops part of this structure to avoid allocation, - // ownership transfer, and delete - CallbackWithSuccessTag(std::function<void(bool)> f, bool self_delete, + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(CallbackWithSuccessTag)); + } + + CallbackWithSuccessTag(grpc_call* call, std::function<void(bool)> f, CompletionQueueTag* ops); - ~CallbackWithSuccessTag() { delete ops_; } + void* tag() { return static_cast<void*>(impl_); } CompletionQueueTag* ops() { return ops_; } |