UniMRCP  1.7.0
apt_poller_task.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_POLLER_TASK_H
18 #define APT_POLLER_TASK_H
19 
20 /**
21  * @file apt_poller_task.h
22  * @brief Poller Task
23  */
24 
25 #include "apt_pollset.h"
26 #include "apt_task.h"
27 #include "apt_timer_queue.h"
28 
30 
31 /** Opaque poller task declaration */
33 
34 /** Function prototype to handle signalled descripors */
35 typedef apt_bool_t (*apt_poll_signal_f)(void *obj, const apr_pollfd_t *descriptor);
36 
37 
38 /**
39  * Create poller task.
40  * @param max_pollset_size the maximum number of descriptors pollset can hold
41  * @param signal_handler the handler of signalled descriptors
42  * @param obj the external object to pass to callback
43  * @param msg_pool the pool of task messages
44  * @param pool the pool to allocate memory from
45  */
47  apr_size_t max_pollset_size,
48  apt_poll_signal_f signal_handler,
49  void *obj,
50  apt_task_msg_pool_t *msg_pool,
51  apr_pool_t *pool);
52 
53 /**
54  * Destroy poller task.
55  * @param task the task to destroy
56  */
58 
59 /**
60  * Cleanup poller task.
61  * @param task the task to cleanup
62  *
63  * @remark This function should be considered in protected scope.
64  * It will be called on task destroy unless you override the behavior.
65  */
67 
68 /**
69  * Start poller task and wait for incoming messages.
70  * @param task the task to start
71  */
73 
74 /**
75  * Terminate poller task.
76  * @param task the task to terminate
77  */
79 
80 /**
81  * Get task base.
82  * @param task the poller task to get task base from
83  */
85 
86 /**
87  * Get task vtable.
88  * @param task the poller task to get vtable from
89  */
91 
92 /**
93  * Get external object.
94  * @param task the poller task to get object from
95  */
97 
98 /**
99  * Add descriptor to pollset.
100  * @param task the task which holds the pollset
101  * @param descriptor the descriptor to add
102  */
103 APT_DECLARE(apt_bool_t) apt_poller_task_descriptor_add(const apt_poller_task_t *task, const apr_pollfd_t *descriptor);
104 
105 /**
106  * Remove descriptor from pollset.
107  * @param task the task which holds the pollset
108  * @param descriptor the descriptor to remove
109  */
110 APT_DECLARE(apt_bool_t) apt_poller_task_descriptor_remove(const apt_poller_task_t *task, const apr_pollfd_t *descriptor);
111 
112 /**
113  * Create timer.
114  * @param task the poller task to create timer in the scope of
115  * @param proc the timer callback
116  * @param obj the object to pass to callback
117  * @param pool the pool to allocate memory from
118  */
120  apt_poller_task_t *task,
121  apt_timer_proc_f proc,
122  void *obj,
123  apr_pool_t *pool);
124 
125 
127 
128 #endif /* APT_POLLER_TASK_H */
void(* apt_timer_proc_f)(apt_timer_t *timer, void *obj)
Definition: apt_timer_queue.h:35
apt_bool_t apt_poller_task_descriptor_remove(const apt_poller_task_t *task, const apr_pollfd_t *descriptor)
apt_bool_t apt_poller_task_destroy(apt_poller_task_t *task)
apt_bool_t apt_poller_task_descriptor_add(const apt_poller_task_t *task, const apr_pollfd_t *descriptor)
Timer Queue.
#define APT_END_EXTERN_C
Definition: apt.h:38
apt_timer_t * apt_poller_task_timer_create(apt_poller_task_t *task, apt_timer_proc_f proc, void *obj, apr_pool_t *pool)
int apt_bool_t
Definition: apt.h:57
Interruptable APR-Pollset.
apt_bool_t apt_poller_task_terminate(apt_poller_task_t *task)
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
typedefAPT_BEGIN_EXTERN_C struct apt_poller_task_t apt_poller_task_t
Definition: apt_poller_task.h:32
#define APT_DECLARE(type)
Definition: apt.h:53
void apt_poller_task_cleanup(apt_poller_task_t *task)
apt_bool_t apt_poller_task_start(apt_poller_task_t *task)
void * apt_poller_task_object_get(const apt_poller_task_t *task)
apt_bool_t(* apt_poll_signal_f)(void *obj, const apr_pollfd_t *descriptor)
Definition: apt_poller_task.h:35
typedefAPT_BEGIN_EXTERN_C struct apt_task_t apt_task_t
Definition: apt_task.h:31
Thread Execution Abstraction.
apt_task_vtable_t * apt_poller_task_vtable_get(const apt_poller_task_t *task)
apt_task_t * apt_poller_task_base_get(const apt_poller_task_t *task)
apt_poller_task_t * apt_poller_task_create(apr_size_t max_pollset_size, apt_poll_signal_f signal_handler, void *obj, apt_task_msg_pool_t *msg_pool, apr_pool_t *pool)
Definition: apt_task.h:224
struct apt_task_msg_pool_t apt_task_msg_pool_t
Definition: apt_task_msg.h:50
typedefAPT_BEGIN_EXTERN_C struct apt_timer_t apt_timer_t
Definition: apt_timer_queue.h:30