UniMRCP  1.7.0
apt_pollset.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 Arsen Chaloyan
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 APT_POLLSET_H
18 #define APT_POLLSET_H
19 
20 /**
21  * @file apt_pollset.h
22  * @brief Interruptable APR-Pollset
23  */
24 
25 /**
26  * Wakeup builtin API of the pollset is introduced only in APR-1.4
27  * and it is not available for APR-1.2 and APR-1.3 versions. Thus
28  * apt_pollset_t is an extension of apr_pollset_t and provides
29  * pollset wakeup capabilities the similar way as it's implemented
30  * in APR-1.4 trunk
31  */
32 
33 #include <apr_poll.h>
34 #include "apt.h"
35 
37 
38 /** Opaque pollset declaration */
40 
41 /**
42  * Create interruptable pollset on top of APR pollset.
43  * @param size the maximum number of descriptors pollset can hold
44  * @param pool the pool to allocate memory from
45  */
46 APT_DECLARE(apt_pollset_t*) apt_pollset_create(apr_uint32_t size, apr_pool_t *pool);
47 
48 /**
49  * Destroy pollset.
50  * @param pollset the pollset to destroy
51  */
53 
54 /**
55  * Add pollset descriptor to a pollset.
56  * @param pollset the pollset to add the descriptor to
57  * @param descriptor the descriptor to add
58  */
59 APT_DECLARE(apt_bool_t) apt_pollset_add(apt_pollset_t *pollset, const apr_pollfd_t *descriptor);
60 
61 /**
62  * Remove pollset descriptor from a pollset.
63  * @param pollset the pollset to remove the descriptor from
64  * @param descriptor the descriptor to remove
65  */
66 APT_DECLARE(apt_bool_t) apt_pollset_remove(apt_pollset_t *pollset, const apr_pollfd_t *descriptor);
67 
68 /**
69  * Block for activity on the descriptor(s) in a pollset.
70  * @param pollset the pollset to use
71  * @param timeout the timeout in microseconds
72  * @param num the number of signalled descriptors (output parameter)
73  * @param descriptors the array of signalled descriptors (output parameter)
74  */
75 APT_DECLARE(apr_status_t) apt_pollset_poll(
76  apt_pollset_t *pollset,
77  apr_interval_time_t timeout,
78  apr_int32_t *num,
79  const apr_pollfd_t **descriptors);
80 
81 /**
82  * Interrupt the blocked poll call.
83  * @param pollset the pollset to use
84  */
86 
87 /**
88  * Match against builtin wake up descriptor in a pollset.
89  * @param pollset the pollset to use
90  * @param descriptor the descriptor to match
91  */
92 APT_DECLARE(apt_bool_t) apt_pollset_is_wakeup(apt_pollset_t *pollset, const apr_pollfd_t *descriptor);
93 
95 
96 #endif /* APT_POLLSET_H */
apt_bool_t apt_pollset_destroy(apt_pollset_t *pollset)
apt_bool_t apt_pollset_add(apt_pollset_t *pollset, const apr_pollfd_t *descriptor)
apr_status_t apt_pollset_poll(apt_pollset_t *pollset, apr_interval_time_t timeout, apr_int32_t *num, const apr_pollfd_t **descriptors)
#define APT_END_EXTERN_C
Definition: apt.h:38
int apt_bool_t
Definition: apt.h:57
apt_pollset_t * apt_pollset_create(apr_uint32_t size, apr_pool_t *pool)
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
#define APT_DECLARE(type)
Definition: apt.h:53
APR Toolkit Definitions.
apt_bool_t apt_pollset_remove(apt_pollset_t *pollset, const apr_pollfd_t *descriptor)
apt_bool_t apt_pollset_wakeup(apt_pollset_t *pollset)
typedefAPT_BEGIN_EXTERN_C struct apt_pollset_t apt_pollset_t
Definition: apt_pollset.h:39
apt_bool_t apt_pollset_is_wakeup(apt_pollset_t *pollset, const apr_pollfd_t *descriptor)