GRPC Core  18.0.0
dynamic_filters.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_DYNAMIC_FILTERS_H
18 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_DYNAMIC_FILTERS_H
19 
21 
22 #include <vector>
23 
30 
31 namespace grpc_core {
32 
33 class DynamicFilters : public RefCounted<DynamicFilters> {
34  public:
35  // Implements the interface of RefCounted<>.
36  class Call {
37  public:
38  struct Args {
42  gpr_cycle_counter start_time;
47  };
48 
50 
51  // Continues processing a transport stream op batch.
53 
54  // Sets the 'then_schedule_closure' argument for call stack destruction.
55  // Must be called once per call.
57 
58  // Interface of RefCounted<>.
60  RefCountedPtr<Call> Ref(const DebugLocation& location,
61  const char* reason) GRPC_MUST_USE_RESULT;
62  // When refcount drops to 0, destroys itself and the associated call stack,
63  // but does NOT free the memory because it's in the call arena.
64  void Unref();
65  void Unref(const DebugLocation& location, const char* reason);
66 
67  private:
68  // Allow RefCountedPtr<> to access IncrementRefCount().
69  template <typename T>
70  friend class RefCountedPtr;
71 
72  // Interface of RefCounted<>.
73  void IncrementRefCount();
74  void IncrementRefCount(const DebugLocation& location, const char* reason);
75 
76  static void Destroy(void* arg, grpc_error_handle error);
77 
78  RefCountedPtr<DynamicFilters> channel_stack_;
79  grpc_closure* after_call_stack_destroy_ = nullptr;
80  };
81 
83  const grpc_channel_args* args,
84  std::vector<const grpc_channel_filter*> filters);
85 
86  explicit DynamicFilters(grpc_channel_stack* channel_stack)
87  : channel_stack_(channel_stack) {}
88 
89  ~DynamicFilters() override;
90 
92 
93  private:
94  grpc_channel_stack* channel_stack_;
95 };
96 
97 } // namespace grpc_core
98 
99 #endif // GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_DYNAMIC_FILTERS_H
Definition: arena.h:44
Definition: call_combiner.h:50
Definition: debug_location.h:31
Definition: dynamic_filters.h:36
void StartTransportStreamOpBatch(grpc_transport_stream_op_batch *batch)
Definition: dynamic_filters.cc:62
void SetAfterCallStackDestroy(grpc_closure *closure)
Definition: dynamic_filters.cc:70
void Unref()
Definition: dynamic_filters.cc:87
Call(Args args, grpc_error_handle *error)
Definition: dynamic_filters.cc:40
RefCountedPtr< Call > Ref() GRPC_MUST_USE_RESULT
Definition: dynamic_filters.cc:76
Definition: dynamic_filters.h:33
~DynamicFilters() override
Definition: dynamic_filters.cc:177
RefCountedPtr< Call > CreateCall(Call::Args args, grpc_error_handle *error)
Definition: dynamic_filters.cc:181
static RefCountedPtr< DynamicFilters > Create(const grpc_channel_args *args, std::vector< const grpc_channel_filter * > filters)
Definition: dynamic_filters.cc:157
Definition: ref_counted.h:282
Definition: ref_counted_ptr.h:35
int64_t grpc_millis
Definition: exec_ctx.h:37
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:524
grpc_error_handle error
Definition: lame_client.cc:54
Round Robin Policy.
Definition: backend_metric.cc:26
grpc_transport_stream_op_batch * batch
Definition: retry_filter.cc:208
grpc_closure closure
Definition: server.cc:460
Definition: context.h:44
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: channel_stack.h:107
Definition: channel_stack.h:182
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
Definition: dynamic_filters.h:38
grpc_call_context_element * context
Definition: dynamic_filters.h:45
CallCombiner * call_combiner
Definition: dynamic_filters.h:46
grpc_slice path
Definition: dynamic_filters.h:41
grpc_polling_entity * pollent
Definition: dynamic_filters.h:40
gpr_cycle_counter start_time
Definition: dynamic_filters.h:42
Arena * arena
Definition: dynamic_filters.h:44
grpc_millis deadline
Definition: dynamic_filters.h:43
RefCountedPtr< DynamicFilters > channel_stack
Definition: dynamic_filters.h:39
Definition: error_internal.h:41
Definition: polling_entity.h:37
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
Definition: transport.h:163