polling_entity.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 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 
20 
22 
23 #include <grpc/support/alloc.h>
24 #include <grpc/support/log.h>
25 
27  grpc_pollset_set* pollset_set) {
28  grpc_polling_entity pollent;
29  pollent.pollent.pollset_set = pollset_set;
30  pollent.tag = GRPC_POLLS_POLLSET_SET;
31  return pollent;
32 }
33 
35  grpc_pollset* pollset) {
36  grpc_polling_entity pollent;
37  pollent.pollent.pollset = pollset;
38  pollent.tag = GRPC_POLLS_POLLSET;
39  return pollent;
40 }
41 
43  if (pollent->tag == GRPC_POLLS_POLLSET) {
44  return pollent->pollent.pollset;
45  }
46  return nullptr;
47 }
48 
50  grpc_polling_entity* pollent) {
51  if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
52  return pollent->pollent.pollset_set;
53  }
54  return nullptr;
55 }
56 
58  return pollent->tag == GRPC_POLLS_NONE;
59 }
60 
62  grpc_pollset_set* pss_dst) {
63  if (pollent->tag == GRPC_POLLS_POLLSET) {
64  // CFStream does not use file destriptors. When CFStream is used, the fd
65  // pollset is possible to be null.
66  if (pollent->pollent.pollset != nullptr) {
67  grpc_pollset_set_add_pollset(pss_dst, pollent->pollent.pollset);
68  }
69  } else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
70  GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
72  } else {
73  gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
74  abort();
75  }
76 }
77 
79  grpc_pollset_set* pss_dst) {
80  if (pollent->tag == GRPC_POLLS_POLLSET) {
81 #ifdef GRPC_CFSTREAM
82  if (pollent->pollent.pollset != nullptr) {
83  grpc_pollset_set_del_pollset(pss_dst, pollent->pollent.pollset);
84  }
85 #else
86  GPR_ASSERT(pollent->pollent.pollset != nullptr);
87  grpc_pollset_set_del_pollset(pss_dst, pollent->pollent.pollset);
88 #endif
89  } else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
90  GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
92  } else {
93  gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
94  abort();
95  }
96 }
grpc_polling_entity_pollset
grpc_pollset * grpc_polling_entity_pollset(grpc_polling_entity *pollent)
Definition: polling_entity.cc:42
GRPC_POLLS_NONE
@ GRPC_POLLS_NONE
Definition: polling_entity.h:29
log.h
polling_entity.h
grpc_polling_entity::tag
grpc_pollset_tag tag
Definition: polling_entity.h:43
grpc_pollset_set
struct grpc_pollset_set grpc_pollset_set
Definition: iomgr_fwd.h:23
GRPC_POLLS_POLLSET
@ GRPC_POLLS_POLLSET
Definition: polling_entity.h:30
grpc_pollset_set_del_pollset_set
void grpc_pollset_set_del_pollset_set(grpc_pollset_set *bag, grpc_pollset_set *item)
Definition: pollset_set.cc:52
GRPC_POLLS_POLLSET_SET
@ GRPC_POLLS_POLLSET_SET
Definition: polling_entity.h:31
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_pollset_set_del_pollset
void grpc_pollset_set_del_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset)
Definition: pollset_set.cc:42
grpc_polling_entity_pollset_set
grpc_pollset_set * grpc_polling_entity_pollset_set(grpc_polling_entity *pollent)
Definition: polling_entity.cc:49
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_polling_entity_create_from_pollset
grpc_polling_entity grpc_polling_entity_create_from_pollset(grpc_pollset *pollset)
Definition: polling_entity.cc:34
grpc_polling_entity_del_from_pollset_set
void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity *pollent, grpc_pollset_set *pss_dst)
Definition: polling_entity.cc:78
grpc_polling_entity
Definition: polling_entity.h:38
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
grpc_polling_entity::pollset_set
grpc_pollset_set * pollset_set
Definition: polling_entity.h:41
grpc_polling_entity_is_empty
bool grpc_polling_entity_is_empty(const grpc_polling_entity *pollent)
Definition: polling_entity.cc:57
grpc_polling_entity::pollent
union grpc_polling_entity::@16 pollent
alloc.h
grpc_pollset_set_add_pollset_set
void grpc_pollset_set_add_pollset_set(grpc_pollset_set *bag, grpc_pollset_set *item)
Definition: pollset_set.cc:47
grpc_polling_entity_add_to_pollset_set
void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity *pollent, grpc_pollset_set *pss_dst)
Definition: polling_entity.cc:61
grpc_polling_entity::pollset
grpc_pollset * pollset
Definition: polling_entity.h:40
grpc_polling_entity_create_from_pollset_set
grpc_polling_entity grpc_polling_entity_create_from_pollset_set(grpc_pollset_set *pollset_set)
Definition: polling_entity.cc:26
grpc_pollset
Definition: bm_cq_multiple_threads.cc:37
grpc_pollset_set_add_pollset
void grpc_pollset_set_add_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset)
Definition: pollset_set.cc:37
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:44