aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++/impl/codegen
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-03-31 09:16:35 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-03-31 09:16:35 -0700
commit66051c618fecc6f9c6b1fa40749c1f267147eb28 (patch)
tree8d0fdf9fbd1c377c4a9e0d90034005eb3f31055d /include/grpc++/impl/codegen
parentdd36b15315cd691e86a94d4574bd9f3e3a33633f (diff)
Async end2end test passes
Diffstat (limited to 'include/grpc++/impl/codegen')
-rw-r--r--include/grpc++/impl/codegen/async_unary_call.h13
-rw-r--r--include/grpc++/impl/codegen/call.h10
-rw-r--r--include/grpc++/impl/codegen/core_codegen.h3
-rw-r--r--include/grpc++/impl/codegen/core_codegen_interface.h3
4 files changed, 20 insertions, 9 deletions
diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h
index dd65cf89d6..b120b37f1f 100644
--- a/include/grpc++/impl/codegen/async_unary_call.h
+++ b/include/grpc++/impl/codegen/async_unary_call.h
@@ -68,10 +68,9 @@ class ClientAsyncResponseReader final
ClientContext* context,
const W& request) {
Call call = channel->CreateCall(method, context, cq);
- ClientAsyncResponseReader* reader = static_cast<ClientAsyncResponseReader*>(
- grpc_call_arena_alloc(call.call(), sizeof(*reader)));
- new (&reader->call_) Call(std::move(call));
- reader->context_ = context;
+ ClientAsyncResponseReader* reader =
+ new (grpc_call_arena_alloc(call.call(), sizeof(*reader)))
+ ClientAsyncResponseReader(call, context);
reader->init_buf_.SendInitialMetadata(context->send_initial_metadata_,
context->initial_metadata_flags());
@@ -107,11 +106,15 @@ class ClientAsyncResponseReader final
}
private:
- ClientContext* context_;
+ ClientContext* const context_;
Call call_;
+ ClientAsyncResponseReader(Call call, ClientContext* context)
+ : context_(context), call_(call) {}
+
// disable operator new
static void* operator new(std::size_t size);
+ static void* operator new(std::size_t size, void* p) { return p; };
SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpClientSendClose>
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h
index 4a52c2cbcf..56dd7b9685 100644
--- a/include/grpc++/impl/codegen/call.h
+++ b/include/grpc++/impl/codegen/call.h
@@ -570,7 +570,7 @@ class CallOpSetInterface : public CompletionQueueTag {
public:
/// Fills in grpc_op, starting from ops[*nops] and moving
/// upwards.
- virtual void FillOps(grpc_op* ops, size_t* nops) = 0;
+ virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0;
};
/// Primary implementaiton of CallOpSetInterface.
@@ -598,10 +598,11 @@ class CallOpSet : public CallOpSetInterface,
this->Op4::AddOp(ops, nops);
this->Op5::AddOp(ops, nops);
this->Op6::AddOp(ops, nops);
- grpc_call_ref(call);
+ g_core_codegen_interface->grpc_call_ref(call);
+ call_ = call;
}
- bool FinalizeResult(grpc_call* call, void** tag, bool* status) override {
+ bool FinalizeResult(void** tag, bool* status) override {
this->Op1::FinishOp(status);
this->Op2::FinishOp(status);
this->Op3::FinishOp(status);
@@ -609,7 +610,7 @@ class CallOpSet : public CallOpSetInterface,
this->Op5::FinishOp(status);
this->Op6::FinishOp(status);
*tag = return_tag_;
- grpc_call_unref(call);
+ g_core_codegen_interface->grpc_call_unref(call_);
return true;
}
@@ -617,6 +618,7 @@ class CallOpSet : public CallOpSetInterface,
private:
void* return_tag_;
+ grpc_call* call_;
};
/// A CallOpSet that does not post completions to the completion queue.
diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h
index 754bf14b25..b579849aca 100644
--- a/include/grpc++/impl/codegen/core_codegen.h
+++ b/include/grpc++/impl/codegen/core_codegen.h
@@ -64,6 +64,9 @@ class CoreCodegen : public CoreCodegenInterface {
void gpr_cv_signal(gpr_cv* cv) override;
void gpr_cv_broadcast(gpr_cv* cv) override;
+ void grpc_call_ref(grpc_call* call) override;
+ void grpc_call_unref(grpc_call* call) override;
+
void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override;
int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h
index 45ea040303..12464591a4 100644
--- a/include/grpc++/impl/codegen/core_codegen_interface.h
+++ b/include/grpc++/impl/codegen/core_codegen_interface.h
@@ -94,6 +94,9 @@ class CoreCodegenInterface {
virtual grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice,
size_t nslices) = 0;
+ virtual void grpc_call_ref(grpc_call* call) = 0;
+ virtual void grpc_call_unref(grpc_call* call) = 0;
+
virtual grpc_slice grpc_slice_malloc(size_t length) = 0;
virtual void grpc_slice_unref(grpc_slice slice) = 0;
virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0;