UniMRCP  1.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
apt_task.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_task.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef APT_TASK_H
20 #define APT_TASK_H
21 
22 /**
23  * @file apt_task.h
24  * @brief Thread Execution Abstraction
25  */
26 
27 #include "apt.h"
28 #include "apt_task_msg.h"
29 
31 
32 /** Opaque task declaration */
33 typedef struct apt_task_t apt_task_t;
34 /** Opaque task virtual table declaration */
36 /** Opaque task method declaration */
38 /** Opaque task event declaration */
39 typedef void (*apt_task_event_f)(apt_task_t *task);
40 
41 
42 /**
43  * Create task.
44  * @param obj the external object to associate with the task
45  * @param msg_pool the pool of task messages
46  * @param pool the pool to allocate memory from
47  */
49  void *obj,
50  apt_task_msg_pool_t *msg_pool,
51  apr_pool_t *pool);
52 
53 /**
54  * Destroy task.
55  * @param task the task to destroy
56  */
58 
59 /**
60  * Add child task.
61  * @param task the task to add child task to
62  * @param child_task the child task to add
63  */
65 
66 /**
67  * Start task.
68  * @param task the task to start
69  */
71 
72 /**
73  * Terminate task.
74  * @param task the task to terminate
75  * @param wait_till_complete whether to wait for task to complete or
76  * process termination asynchronously
77  */
79 
80 /**
81  * Start child tasks.
82  * @param task the parent task
83  */
85 
86 /**
87  * Terminate child tasks.
88  * @param task the parent task
89  */
91 
92 /**
93  * Wait for task till complete.
94  * @param task the task to wait for
95  */
97 
98 /**
99  * Get (acquire) task message.
100  * @param task the task to get task message from
101  */
103 
104 /**
105  * Signal (post) message to the task.
106  * @param task the task to signal message to
107  * @param msg the message to signal
108  */
110 
111 /**
112  * Signal (post) message to the parent of the specified task.
113  * @param task the task to signal message to
114  * @param msg the message to signal
115  */
117 
118 /**
119  * Process message signaled to the task.
120  * @param task the task to process message
121  * @param msg the message to process
122  */
124 
125 /**
126  * Get parent (master) task.
127  * @param task the task to get parent from
128  */
130 
131 /**
132  * Get memory pool associated with task.
133  * @param task the task to get pool from
134  */
135 APT_DECLARE(apr_pool_t*) apt_task_pool_get(const apt_task_t *task);
136 
137 /**
138  * Get external object associated with the task.
139  * @param task the task to get object from
140  */
141 APT_DECLARE(void*) apt_task_object_get(const apt_task_t *task);
142 
143 /**
144  * Get task vtable.
145  * @param task the task to get vtable from
146  */
148 
149 /**
150  * Give a name to the task.
151  * @param task the task to give name for
152  * @param name the name to set
153  */
154 APT_DECLARE(void) apt_task_name_set(apt_task_t *task, const char *name);
155 
156 /**
157  * Get task name.
158  * @param task the task to get name from
159  */
160 APT_DECLARE(const char*) apt_task_name_get(const apt_task_t *task);
161 
162 /**
163  * Enable/disable auto ready mode.
164  * @param task the task to set mode for
165  * @param auto_ready the enabled/disabled auto ready mode
166  */
168 
169 /**
170  * Explicitly indicate task is ready to process messages.
171  * @param task the task
172  */
174 
175 /**
176  * Get the running flag.
177  * @param task the task
178  */
180 
181 /**
182  * Add start request.
183  * @param task the task
184  */
186 
187 /**
188  * Remove start request.
189  * @param task the task
190  */
192 
193 /**
194  * Add termination request.
195  * @param task the task
196  */
198 
199 /**
200  * Remove termination request.
201  * @param task the task
202  */
204 
205 /**
206  * Hold task execution.
207  * @param msec the time to hold
208  */
209 APT_DECLARE(void) apt_task_delay(apr_size_t msec);
210 
211 
212 /** Table of task virtual methods */
214  /** Virtual destroy method */
216  /** Virtual start method*/
218  /** Virtual terminate method */
220  /** Virtual run method*/
222 
223  /** Virtual signal method */
225  /** Virtual process method */
227 
228  /** Virtual pre-run event handler */
230  /** Virtual post-run event handler */
232  /** Virtual start-request event handler */
234  /** Virtual start-complete event handler */
236  /** Virtual terminate-request event handler */
238  /** Virtual terminate-complete event handler */
240 };
241 
243 
244 #endif /* APT_TASK_H */