aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpcpp/impl/codegen/client_callback.h
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-08-30 17:21:07 -0700
committerGravatar Vijay Pai <vpai@google.com>2018-08-31 10:11:38 -0700
commit5474e92292a37ea9017db02da1e8e6aea621b156 (patch)
treedf57fcffedd27789a438d95d5296001392987c16 /include/grpcpp/impl/codegen/client_callback.h
parentd4afae9a56ff0f5b9b3cda380c0b9c64be170f87 (diff)
Allocate using call arenas
Diffstat (limited to 'include/grpcpp/impl/codegen/client_callback.h')
-rw-r--r--include/grpcpp/impl/codegen/client_callback.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h
index 419933f85c..fc81c8aa0a 100644
--- a/include/grpcpp/impl/codegen/client_callback.h
+++ b/include/grpcpp/impl/codegen/client_callback.h
@@ -57,18 +57,21 @@ class CallbackUnaryCallImpl {
std::function<void(Status)> on_completion) {
CompletionQueue* cq = channel->CallbackCQ();
GPR_CODEGEN_ASSERT(cq != nullptr);
+ Call call(channel->CreateCall(method, context, cq));
+
+ using FullCallOpSet =
+ CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
+ CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>,
+ CallOpClientSendClose, CallOpClientRecvStatus>;
- // TODO(vjpai): Allocate this as part of the tag's arena
- auto* ops = new CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpRecvInitialMetadata,
- CallOpRecvMessage<OutputMessage>,
- CallOpClientSendClose, CallOpClientRecvStatus>;
+ auto* ops = new (g_core_codegen_interface->grpc_call_arena_alloc(
+ call.call(), sizeof(FullCallOpSet))) FullCallOpSet;
- // TODO(vjpai): Move to using pre-allocated tags rather than new/self-delete
- auto* tag = new CallbackWithStatusTag(on_completion, true, ops);
+ auto* tag = new (g_core_codegen_interface->grpc_call_arena_alloc(
+ call.call(), sizeof(CallbackWithStatusTag)))
+ CallbackWithStatusTag(call.call(), on_completion, ops);
// TODO(vjpai): Unify code with sync API as much as possible
- Call call(channel->CreateCall(method, context, cq));
Status s = ops->SendMessage(*request);
if (!s.ok()) {
tag->force_run(s);