GRPC C++  1.26.0
channel.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_SURFACE_CHANNEL_H
20 #define GRPC_CORE_LIB_SURFACE_CHANNEL_H
21 
23 
28 
29 grpc_channel* grpc_channel_create(const char* target,
30  const grpc_channel_args* args,
31  grpc_channel_stack_type channel_stack_type,
32  grpc_transport* optional_transport,
33  grpc_resource_user* resource_user = nullptr);
34 
38 
41  grpc_channel_stack_type channel_stack_type);
42 
52  grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
53  grpc_pollset_set* pollset_set, const grpc_slice& method,
54  const grpc_slice* host, grpc_millis deadline, void* reserved);
55 
58 
60  grpc_channel* channel);
61 
63 void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size);
64 
65 struct registered_call;
66 struct grpc_channel {
67  int is_client;
69 
72 
74  registered_call* registered_calls;
75 
77 
78  char* target;
79 };
80 #define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack*)((c) + 1))
81 
83  const grpc_channel* channel) {
84  return channel->compression_options;
85 }
86 
88  grpc_channel* channel) {
89  return CHANNEL_STACK_FROM_CHANNEL(channel);
90 }
91 
93  grpc_channel* channel) {
94  return channel->channelz_node.get();
95 }
96 
97 #ifndef NDEBUG
99  const char* reason) {
101 }
103  const char* reason) {
105 }
106 #define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
107  grpc_channel_internal_ref(channel, reason)
108 #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
109  grpc_channel_internal_unref(channel, reason)
110 #else
111 inline void grpc_channel_internal_ref(grpc_channel* channel) {
113 }
114 inline void grpc_channel_internal_unref(grpc_channel* channel) {
116 }
117 #define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
118  grpc_channel_internal_ref(channel)
119 #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
120  grpc_channel_internal_unref(channel)
121 #endif
122 
125  const grpc_channel* channel);
126 
127 #endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:70
Definition: channel_stack.h:175
int64_t grpc_millis
Definition: exec_ctx.h:35
gpr_atm call_size_estimate
Definition: channel.h:70
gpr_mu registered_call_mu
Definition: channel.h:73
grpc_channel * grpc_channel_create_with_builder(grpc_channel_stack_builder *builder, grpc_channel_stack_type channel_stack_type)
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: channel.h:66
Definition: compression_types.h:79
grpc_channel * grpc_channel_create(const char *target, const grpc_channel_args *args, grpc_channel_stack_type channel_stack_type, grpc_transport *optional_transport, grpc_resource_user *resource_user=nullptr)
registered_call * registered_calls
Definition: channel.h:74
void grpc_channel_internal_ref(grpc_channel *channel, const char *reason)
Definition: channel.h:98
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:60
grpc_compression_options compression_options
Definition: channel.h:68
grpc_core::channelz::ChannelNode * grpc_channel_get_channelz_node(grpc_channel *channel)
Definition: channel.h:92
size_t grpc_channel_get_call_size_estimate(grpc_channel *channel)
grpc_channel_stack_type
Definition: channel_stack_type.h:26
int is_client
Definition: channel.h:67
struct grpc_resource_user grpc_resource_user
Definition: resource_quota.h:87
grpc_call * grpc_channel_create_pollset_set_call(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_pollset_set *pollset_set, const grpc_slice &method, const grpc_slice *host, grpc_millis deadline, void *reserved)
Create a call given a grpc_channel, in order to call method.
Definition: sync_windows.h:26
struct grpc_channel_stack_builder grpc_channel_stack_builder
grpc_channel_stack_builder offers a programmatic interface to selected and order channel filters ...
Definition: channel_stack_builder.h:31
intptr_t gpr_atm
Definition: atm_gcc_atomic.h:30
struct grpc_pollset_set grpc_pollset_set
Definition: pollset_set.h:31
char * target
Definition: channel.h:78
grpc_compression_options grpc_channel_compression_options(const grpc_channel *channel)
Return the channel's compression options.
Definition: channel.h:82
grpc_channel_stack * grpc_channel_get_channel_stack(grpc_channel *channel)
Get a (borrowed) pointer to this channels underlying channel stack.
Definition: channel.h:87
grpc_core::RefCountedPtr< grpc_core::channelz::ChannelNode > channelz_node
Definition: channel.h:76
T * get() const
Definition: ref_counted_ptr.h:144
void grpc_channel_update_call_size_estimate(grpc_channel *channel, size_t size)
#define GRPC_CHANNEL_STACK_REF(channel_stack, reason)
Definition: channel_stack.h:232
grpc_resource_user * resource_user
Definition: channel.h:71
void grpc_channel_internal_unref(grpc_channel *channel, const char *reason)
Definition: channel.h:102
#define CHANNEL_STACK_FROM_CHANNEL(c)
Definition: channel.h:80
void grpc_channel_destroy_internal(grpc_channel *channel)
The same as grpc_channel_destroy, but doesn&#39;t create an ExecCtx, and so is safe to use from within co...
Definition: transport_impl.h:66
Definition: channelz.h:169
#define GRPC_CHANNEL_STACK_UNREF(channel_stack, reason)
Definition: channel_stack.h:234