diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-12-06 09:05:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 09:05:05 -0800 |
commit | ad4d2dde0052efbbf49d64b0843c45f0381cfeb3 (patch) | |
tree | 6a657f8c6179d873b34505cdc24bce9462ca68eb /src/cpp/common | |
parent | a3df36cc2505a89c2f481eea4a66a87b3002844a (diff) |
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.cc | 11 | ||||
-rw-r--r-- | src/cpp/common/channel_filter.cc | 29 | ||||
-rw-r--r-- | src/cpp/common/channel_filter.h | 62 |
3 files changed, 60 insertions, 42 deletions
diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index b696774243..cae9ef953a 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -66,12 +66,13 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other) } ChannelArguments::~ChannelArguments() { - grpc_core::ExecCtx exec_ctx; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; for (auto it = args_.begin(); it != args_.end(); ++it) { if (it->type == GRPC_ARG_POINTER) { - it->value.pointer.vtable->destroy(it->value.pointer.p); + it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p); } } + grpc_exec_ctx_finish(&exec_ctx); } void ChannelArguments::Swap(ChannelArguments& other) { @@ -94,17 +95,17 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) { } grpc_arg mutator_arg = grpc_socket_mutator_to_arg(mutator); bool replaced = false; - grpc_core::ExecCtx exec_ctx; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; 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(it->value.pointer.p); + it->value.pointer.vtable->destroy(&exec_ctx, 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 cbe2a209f5..274079f8dd 100644 --- a/src/cpp/common/channel_filter.cc +++ b/src/cpp/common/channel_filter.cc @@ -27,39 +27,43 @@ namespace grpc { // MetadataBatch -grpc_linked_mdelem* MetadataBatch::AddMetadata(const string& key, +grpc_linked_mdelem* MetadataBatch::AddMetadata(grpc_exec_ctx* exec_ctx, + 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(SliceFromCopiedString(key), + storage->md = grpc_mdelem_from_slices(exec_ctx, SliceFromCopiedString(key), SliceFromCopiedString(value)); GRPC_LOG_IF_ERROR("MetadataBatch::AddMetadata", - grpc_metadata_batch_link_head(batch_, storage)); + grpc_metadata_batch_link_head(exec_ctx, batch_, storage)); return storage; } // ChannelData -void ChannelData::StartTransportOp(grpc_channel_element* elem, +void ChannelData::StartTransportOp(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, TransportOp* op) { - grpc_channel_next_op(elem, op->op()); + grpc_channel_next_op(exec_ctx, elem, op->op()); } -void ChannelData::GetInfo(grpc_channel_element* elem, +void ChannelData::GetInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, const grpc_channel_info* channel_info) { - grpc_channel_next_get_info(elem, channel_info); + grpc_channel_next_get_info(exec_ctx, elem, channel_info); } // CallData -void CallData::StartTransportStreamOpBatch(grpc_call_element* elem, +void CallData::StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, TransportStreamOpBatch* op) { - grpc_call_next_op(elem, op->op()); + grpc_call_next_op(exec_ctx, elem, op->op()); } -void CallData::SetPollsetOrPollsetSet(grpc_call_element* elem, +void CallData::SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, grpc_polling_entity* pollent) { - grpc_call_stack_ignore_set_pollset_or_pollset_set(elem, pollent); + grpc_call_stack_ignore_set_pollset_or_pollset_set(exec_ctx, elem, pollent); } // internal code used by RegisterChannelFilter() @@ -71,7 +75,8 @@ std::vector<FilterRecord>* channel_filters; namespace { -bool MaybeAddFilter(grpc_channel_stack_builder* builder, void* arg) { +bool MaybeAddFilter(grpc_exec_ctx* exec_ctx, + 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 a1f42c0b32..9fe9cf0aea 100644 --- a/src/cpp/common/channel_filter.h +++ b/src/cpp/common/channel_filter.h @@ -54,7 +54,8 @@ 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(const string& key, const string& value); + grpc_linked_mdelem* AddMetadata(grpc_exec_ctx* exec_ctx, const string& key, + const string& value); class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const grpc_mdelem> { @@ -221,17 +222,18 @@ 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_channel_element* elem, + virtual grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } // Called before destruction. - virtual void Destroy(grpc_channel_element* elem) {} + virtual void Destroy(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {} - virtual void StartTransportOp(grpc_channel_element* elem, TransportOp* op); + virtual void StartTransportOp(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, TransportOp* op); - virtual void GetInfo(grpc_channel_element* elem, + virtual void GetInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, const grpc_channel_info* channel_info); }; @@ -244,22 +246,24 @@ 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_call_element* elem, + virtual grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, const grpc_call_element_args* args) { return GRPC_ERROR_NONE; } // Called before destruction. - virtual void Destroy(grpc_call_element* elem, + virtual void Destroy(grpc_exec_ctx* exec_ctx, 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_call_element* elem, + virtual void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, TransportStreamOpBatch* op); /// Sets a pollset or pollset set. - virtual void SetPollsetOrPollsetSet(grpc_call_element* elem, + virtual void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, grpc_polling_entity* pollent); }; @@ -273,63 +277,71 @@ class ChannelFilter final { public: static const size_t channel_data_size = sizeof(ChannelDataType); - static grpc_error* InitChannelElement(grpc_channel_element* elem, + static grpc_error* InitChannelElement(grpc_exec_ctx* exec_ctx, + 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(elem, args); + return channel_data->Init(exec_ctx, elem, args); } - static void DestroyChannelElement(grpc_channel_element* elem) { + static void DestroyChannelElement(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) { ChannelDataType* channel_data = reinterpret_cast<ChannelDataType*>(elem->channel_data); - channel_data->Destroy(elem); + channel_data->Destroy(exec_ctx, elem); channel_data->~ChannelDataType(); } - static void StartTransportOp(grpc_channel_element* elem, + static void StartTransportOp(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, grpc_transport_op* op) { ChannelDataType* channel_data = reinterpret_cast<ChannelDataType*>(elem->channel_data); TransportOp op_wrapper(op); - channel_data->StartTransportOp(elem, &op_wrapper); + channel_data->StartTransportOp(exec_ctx, elem, &op_wrapper); } - static void GetChannelInfo(grpc_channel_element* elem, + static void GetChannelInfo(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, const grpc_channel_info* channel_info) { ChannelDataType* channel_data = reinterpret_cast<ChannelDataType*>(elem->channel_data); - channel_data->GetInfo(elem, channel_info); + channel_data->GetInfo(exec_ctx, elem, channel_info); } static const size_t call_data_size = sizeof(CallDataType); - static grpc_error* InitCallElement(grpc_call_element* elem, + static grpc_error* InitCallElement(grpc_exec_ctx* exec_ctx, + 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(elem, args); + return call_data->Init(exec_ctx, elem, args); } - static void DestroyCallElement(grpc_call_element* elem, + static void DestroyCallElement(grpc_exec_ctx* exec_ctx, + 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(elem, final_info, then_call_closure); + call_data->Destroy(exec_ctx, elem, final_info, then_call_closure); call_data->~CallDataType(); } - static void StartTransportStreamOpBatch(grpc_call_element* elem, + static void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx, + 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(elem, &op_wrapper); + call_data->StartTransportStreamOpBatch(exec_ctx, elem, &op_wrapper); } - static void SetPollsetOrPollsetSet(grpc_call_element* elem, + static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, grpc_polling_entity* pollent) { CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data); - call_data->SetPollsetOrPollsetSet(elem, pollent); + call_data->SetPollsetOrPollsetSet(exec_ctx, elem, pollent); } }; |