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