UniMRCP  1.3.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 2180 2014-09-13 21:17:24Z 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  * Take task offline.
74  * @param task the task to take offline
75  */
77 
78 /**
79  * Bring task online.
80  * @param task the task to bring online
81  */
83 
84 /**
85  * Terminate task.
86  * @param task the task to terminate
87  * @param wait_till_complete whether to wait for task to complete or
88  * process termination asynchronously
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  * Process task start request.
127  * @param task the task being started
128  */
130 
131 /**
132  * Process task termination request.
133  * @param task the task being terminated
134  */
136 
137 
138 /**
139  * Get parent (master) task.
140  * @param task the task to get parent from
141  */
143 
144 /**
145  * Get memory pool associated with task.
146  * @param task the task to get pool from
147  */
148 APT_DECLARE(apr_pool_t*) apt_task_pool_get(const apt_task_t *task);
149 
150 /**
151  * Get external object associated with the task.
152  * @param task the task to get object from
153  */
154 APT_DECLARE(void*) apt_task_object_get(const apt_task_t *task);
155 
156 /**
157  * Get task vtable.
158  * @param task the task to get vtable from
159  */
161 
162 /**
163  * Give a name to the task.
164  * @param task the task to give name for
165  * @param name the name to set
166  */
167 APT_DECLARE(void) apt_task_name_set(apt_task_t *task, const char *name);
168 
169 /**
170  * Get task name.
171  * @param task the task to get name from
172  */
173 APT_DECLARE(const char*) apt_task_name_get(const apt_task_t *task);
174 
175 /**
176  * Enable/disable auto ready mode.
177  * @param task the task to set mode for
178  * @param auto_ready the enabled/disabled auto ready mode
179  */
181 
182 /**
183  * Explicitly indicate task is ready to process messages.
184  * @param task the task
185  */
187 
188 /**
189  * Get the running flag.
190  * @param task the task
191  */
193 
194 /**
195  * Add start request.
196  * @param task the task
197  */
199 
200 /**
201  * Remove start request.
202  * @param task the task
203  */
205 
206 /**
207  * Add termination request.
208  * @param task the task
209  */
211 
212 /**
213  * Remove termination request.
214  * @param task the task
215  */
217 
218 /**
219  * Hold task execution.
220  * @param msec the time to hold
221  */
222 APT_DECLARE(void) apt_task_delay(apr_size_t msec);
223 
224 
225 /** Table of task virtual methods */
227  /** Virtual destroy method */
229  /** Virtual start method*/
231  /** Virtual terminate method */
233  /** Virtual run method*/
235 
236  /** Virtual signal_msg method */
238  /** Virtual process_msg method */
240 
241  /** Virtual process_start method */
243  /** Virtual process_terminate method */
245 
246  /** Virtual pre-run event handler */
248  /** Virtual post-run event handler */
250  /** Virtual start-complete event handler */
252  /** Virtual terminate-complete event handler */
254  /** Virtual take-offline-complete event handler */
256  /** Virtual bring-online-complete event handler */
258 };
259 
261 
262 #endif /* APT_TASK_H */