3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H
20 #define GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H
22 #include <grpc/support/port_platform.h>
24 #include "src/core/lib/iomgr/pollset.h"
25 #include "src/core/lib/iomgr/pollset_set.h"
27 typedef enum grpc_pollset_tag {
30 GRPC_POLLS_POLLSET_SET
33 /* A grpc_polling_entity is a pollset-or-pollset_set container. It allows
34 * functions that accept a pollset XOR a pollset_set to do so through an
35 * abstract interface. No ownership is taken. */
37 struct grpc_polling_entity {
39 grpc_pollset* pollset = nullptr;
40 grpc_pollset_set* pollset_set;
42 grpc_pollset_tag tag = GRPC_POLLS_NONE;
45 grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
46 grpc_pollset_set* pollset_set);
47 grpc_polling_entity grpc_polling_entity_create_from_pollset(
48 grpc_pollset* pollset);
50 /** If \a pollent contains a pollset, return it. Otherwise, return NULL */
51 grpc_pollset* grpc_polling_entity_pollset(grpc_polling_entity* pollent);
53 /** If \a pollent contains a pollset_set, return it. Otherwise, return NULL */
54 grpc_pollset_set* grpc_polling_entity_pollset_set(grpc_polling_entity* pollent);
56 bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent);
58 /** Add the pollset or pollset_set in \a pollent to the destination pollset_set
60 void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent,
61 grpc_pollset_set* pss_dst);
63 /** Delete the pollset or pollset_set in \a pollent from the destination
64 * pollset_set \a * pss_dst */
65 void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent,
66 grpc_pollset_set* pss_dst);
68 #endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */