aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/common
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-12-06 09:47:54 -0800
committerGravatar GitHub <noreply@github.com>2017-12-06 09:47:54 -0800
commit8cf1470a51ea276ca84825e7495d4ee24743540d (patch)
tree72385cc865094115bc08cb813201d48cb09840bb /src/cpp/common
parent1d4e99508409be052bd129ba507bae1fbe7eb7fa (diff)
Revert "Revert "All instances of exec_ctx being passed around in src/core removed""
Diffstat (limited to 'src/cpp/common')
-rw-r--r--src/cpp/common/channel_arguments.cc11
-rw-r--r--src/cpp/common/channel_filter.cc29
-rw-r--r--src/cpp/common/channel_filter.h62
3 files changed, 42 insertions, 60 deletions
diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc
index cae9ef953a..b696774243 100644
--- a/src/cpp/common/channel_arguments.cc
+++ b/src/cpp/common/channel_arguments.cc
@@ -66,13 +66,12 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
}
ChannelArguments::~ChannelArguments() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
for (auto it = args_.begin(); it != args_.end(); ++it) {
if (it->type == GRPC_ARG_POINTER) {
- it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p);
+ it->value.pointer.vtable->destroy(it->value.pointer.p);
}
}
- grpc_exec_ctx_finish(&exec_ctx);
}
void ChannelArguments::Swap(ChannelArguments& other) {
@@ -95,17 +94,17 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
}
grpc_arg mutator_arg = grpc_socket_mutator_to_arg(mutator);
bool replaced = false;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
for (auto it = args_.begin(); it != args_.end(); ++it) {
if (it->type == mutator_arg.type &&
grpc::string(it->key) == grpc::string(mutator_arg.key)) {
GPR_ASSERT(!replaced);
- it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p);
+ it->value.pointer.vtable->destroy(it->value.pointer.p);
it->value.pointer = mutator_arg.value.pointer;
replaced = true;
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
if (!replaced) {
args_.push_back(mutator_arg);
}
diff --git a/src/cpp/common/channel_filter.cc b/src/cpp/common/channel_filter.cc
index 274079f8dd..cbe2a209f5 100644
--- a/src/cpp/common/channel_filter.cc
+++ b/src/cpp/common/channel_filter.cc
@@ -27,43 +27,39 @@ namespace grpc {
// MetadataBatch
-grpc_linked_mdelem* MetadataBatch::AddMetadata(grpc_exec_ctx* exec_ctx,
- const string& key,
+grpc_linked_mdelem* MetadataBatch::AddMetadata(const string& key,
const string& value) {
grpc_linked_mdelem* storage = new grpc_linked_mdelem;
memset(storage, 0, sizeof(grpc_linked_mdelem));
- storage->md = grpc_mdelem_from_slices(exec_ctx, SliceFromCopiedString(key),
+ storage->md = grpc_mdelem_from_slices(SliceFromCopiedString(key),
SliceFromCopiedString(value));
GRPC_LOG_IF_ERROR("MetadataBatch::AddMetadata",
- grpc_metadata_batch_link_head(exec_ctx, batch_, storage));
+ grpc_metadata_batch_link_head(batch_, storage));
return storage;
}
// ChannelData
-void ChannelData::StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+void ChannelData::StartTransportOp(grpc_channel_element* elem,
TransportOp* op) {
- grpc_channel_next_op(exec_ctx, elem, op->op());
+ grpc_channel_next_op(elem, op->op());
}
-void ChannelData::GetInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+void ChannelData::GetInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {
- grpc_channel_next_get_info(exec_ctx, elem, channel_info);
+ grpc_channel_next_get_info(elem, channel_info);
}
// CallData
-void CallData::StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+void CallData::StartTransportStreamOpBatch(grpc_call_element* elem,
TransportStreamOpBatch* op) {
- grpc_call_next_op(exec_ctx, elem, op->op());
+ grpc_call_next_op(elem, op->op());
}
-void CallData::SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+void CallData::SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {
- grpc_call_stack_ignore_set_pollset_or_pollset_set(exec_ctx, elem, pollent);
+ grpc_call_stack_ignore_set_pollset_or_pollset_set(elem, pollent);
}
// internal code used by RegisterChannelFilter()
@@ -75,8 +71,7 @@ std::vector<FilterRecord>* channel_filters;
namespace {
-bool MaybeAddFilter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+bool MaybeAddFilter(grpc_channel_stack_builder* builder, void* arg) {
const FilterRecord& filter = *(FilterRecord*)arg;
if (filter.include_filter) {
const grpc_channel_args* args =
diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h
index 9fe9cf0aea..a1f42c0b32 100644
--- a/src/cpp/common/channel_filter.h
+++ b/src/cpp/common/channel_filter.h
@@ -54,8 +54,7 @@ class MetadataBatch {
/// Adds metadata and returns the newly allocated storage.
/// The caller takes ownership of the result, which must exist for the
/// lifetime of the gRPC call.
- grpc_linked_mdelem* AddMetadata(grpc_exec_ctx* exec_ctx, const string& key,
- const string& value);
+ grpc_linked_mdelem* AddMetadata(const string& key, const string& value);
class const_iterator : public std::iterator<std::bidirectional_iterator_tag,
const grpc_mdelem> {
@@ -222,18 +221,17 @@ class ChannelData {
// TODO(roth): Come up with a more C++-like API for the channel element.
/// Initializes the channel data.
- virtual grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ virtual grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {}
+ virtual void Destroy(grpc_channel_element* elem) {}
- virtual void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem, TransportOp* op);
+ virtual void StartTransportOp(grpc_channel_element* elem, TransportOp* op);
- virtual void GetInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ virtual void GetInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info);
};
@@ -246,24 +244,22 @@ class CallData {
// TODO(roth): Come up with a more C++-like API for the call element.
/// Initializes the call data.
- virtual grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ virtual grpc_error* Init(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ virtual void Destroy(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_call_closure) {}
/// Starts a new stream operation.
- virtual void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ virtual void StartTransportStreamOpBatch(grpc_call_element* elem,
TransportStreamOpBatch* op);
/// Sets a pollset or pollset set.
- virtual void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ virtual void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent);
};
@@ -277,71 +273,63 @@ class ChannelFilter final {
public:
static const size_t channel_data_size = sizeof(ChannelDataType);
- static grpc_error* InitChannelElement(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+ static grpc_error* InitChannelElement(grpc_channel_element* elem,
grpc_channel_element_args* args) {
// Construct the object in the already-allocated memory.
ChannelDataType* channel_data = new (elem->channel_data) ChannelDataType();
- return channel_data->Init(exec_ctx, elem, args);
+ return channel_data->Init(elem, args);
}
- static void DestroyChannelElement(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+ static void DestroyChannelElement(grpc_channel_element* elem) {
ChannelDataType* channel_data =
reinterpret_cast<ChannelDataType*>(elem->channel_data);
- channel_data->Destroy(exec_ctx, elem);
+ channel_data->Destroy(elem);
channel_data->~ChannelDataType();
}
- static void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+ static void StartTransportOp(grpc_channel_element* elem,
grpc_transport_op* op) {
ChannelDataType* channel_data =
reinterpret_cast<ChannelDataType*>(elem->channel_data);
TransportOp op_wrapper(op);
- channel_data->StartTransportOp(exec_ctx, elem, &op_wrapper);
+ channel_data->StartTransportOp(elem, &op_wrapper);
}
- static void GetChannelInfo(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+ static void GetChannelInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {
ChannelDataType* channel_data =
reinterpret_cast<ChannelDataType*>(elem->channel_data);
- channel_data->GetInfo(exec_ctx, elem, channel_info);
+ channel_data->GetInfo(elem, channel_info);
}
static const size_t call_data_size = sizeof(CallDataType);
- static grpc_error* InitCallElement(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static grpc_error* InitCallElement(grpc_call_element* elem,
const grpc_call_element_args* args) {
// Construct the object in the already-allocated memory.
CallDataType* call_data = new (elem->call_data) CallDataType();
- return call_data->Init(exec_ctx, elem, args);
+ return call_data->Init(elem, args);
}
- static void DestroyCallElement(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static void DestroyCallElement(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_call_closure) {
CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
- call_data->Destroy(exec_ctx, elem, final_info, then_call_closure);
+ call_data->Destroy(elem, final_info, then_call_closure);
call_data->~CallDataType();
}
- static void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static void StartTransportStreamOpBatch(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
TransportStreamOpBatch op_wrapper(op);
- call_data->StartTransportStreamOpBatch(exec_ctx, elem, &op_wrapper);
+ call_data->StartTransportStreamOpBatch(elem, &op_wrapper);
}
- static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {
CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
- call_data->SetPollsetOrPollsetSet(exec_ctx, elem, pollent);
+ call_data->SetPollsetOrPollsetSet(elem, pollent);
}
};