UniMRCP
1.3.0
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
libs
apr-toolkit
include
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
30
APT_BEGIN_EXTERN_C
31
32
/** Opaque task declaration */
33
typedef
struct
apt_task_t
apt_task_t
;
34
/** Opaque task virtual table declaration */
35
typedef
struct
apt_task_vtable_t
apt_task_vtable_t
;
36
/** Opaque task method declaration */
37
typedef
apt_bool_t
(*
apt_task_method_f
)(
apt_task_t
*task);
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
*/
48
APT_DECLARE
(
apt_task_t
*)
apt_task_create
(
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
*/
57
APT_DECLARE
(
apt_bool_t
)
apt_task_destroy
(
apt_task_t
*task);
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
*/
64
APT_DECLARE
(
apt_bool_t
)
apt_task_add
(
apt_task_t
*task,
apt_task_t
*child_task);
65
66
/**
67
* Start task.
68
* @param task the task to start
69
*/
70
APT_DECLARE
(
apt_bool_t
)
apt_task_start
(
apt_task_t
*task);
71
72
/**
73
* Take task offline.
74
* @param task the task to take offline
75
*/
76
APT_DECLARE
(
apt_bool_t
)
apt_task_offline
(
apt_task_t
*task);
77
78
/**
79
* Bring task online.
80
* @param task the task to bring online
81
*/
82
APT_DECLARE
(
apt_bool_t
)
apt_task_online
(
apt_task_t
*task);
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
*/
90
APT_DECLARE
(
apt_bool_t
)
apt_task_terminate
(
apt_task_t
*task,
apt_bool_t
wait_till_complete);
91
92
/**
93
* Wait for task till complete.
94
* @param task the task to wait for
95
*/
96
APT_DECLARE
(
apt_bool_t
)
apt_task_wait_till_complete
(
apt_task_t
*task);
97
98
/**
99
* Get (acquire) task message.
100
* @param task the task to get task message from
101
*/
102
APT_DECLARE
(
apt_task_msg_t
*)
apt_task_msg_get
(
apt_task_t
*task);
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
*/
109
APT_DECLARE
(
apt_bool_t
)
apt_task_msg_signal
(
apt_task_t
*task,
apt_task_msg_t
*msg);
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
*/
116
APT_DECLARE
(
apt_bool_t
)
apt_task_msg_parent_signal
(
apt_task_t
*task,
apt_task_msg_t
*msg);
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
*/
123
APT_DECLARE
(
apt_bool_t
)
apt_task_msg_process
(
apt_task_t
*task,
apt_task_msg_t
*msg);
124
125
/**
126
* Process task start request.
127
* @param task the task being started
128
*/
129
APT_DECLARE
(
apt_bool_t
)
apt_task_start_request_process
(
apt_task_t
*task);
130
131
/**
132
* Process task termination request.
133
* @param task the task being terminated
134
*/
135
APT_DECLARE
(
apt_bool_t
)
apt_task_terminate_request_process
(
apt_task_t
*task);
136
137
138
/**
139
* Get parent (master) task.
140
* @param task the task to get parent from
141
*/
142
APT_DECLARE
(
apt_task_t
*)
apt_task_parent_get
(const
apt_task_t
*task);
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
*/
160
APT_DECLARE
(
apt_task_vtable_t
*)
apt_task_vtable_get
(
apt_task_t
*task);
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
*/
180
APT_DECLARE
(
void
)
apt_task_auto_ready_set
(
apt_task_t
*task,
apt_bool_t
auto_ready);
181
182
/**
183
* Explicitly indicate task is ready to process messages.
184
* @param task the task
185
*/
186
APT_DECLARE
(
apt_bool_t
)
apt_task_ready
(
apt_task_t
*task);
187
188
/**
189
* Get the running flag.
190
* @param task the task
191
*/
192
APT_DECLARE
(
apt_bool_t
*)
apt_task_running_flag_get
(
apt_task_t
*task);
193
194
/**
195
* Add start request.
196
* @param task the task
197
*/
198
APT_DECLARE
(
apt_bool_t
)
apt_task_start_request_add
(
apt_task_t
*task);
199
200
/**
201
* Remove start request.
202
* @param task the task
203
*/
204
APT_DECLARE
(
apt_bool_t
)
apt_task_start_request_remove
(
apt_task_t
*task);
205
206
/**
207
* Add termination request.
208
* @param task the task
209
*/
210
APT_DECLARE
(
apt_bool_t
)
apt_task_terminate_request_add
(
apt_task_t
*task);
211
212
/**
213
* Remove termination request.
214
* @param task the task
215
*/
216
APT_DECLARE
(
apt_bool_t
)
apt_task_terminate_request_remove
(
apt_task_t
*task);
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 */
226
struct
apt_task_vtable_t
{
227
/** Virtual destroy method */
228
apt_task_method_f
destroy
;
229
/** Virtual start method*/
230
apt_task_method_f
start
;
231
/** Virtual terminate method */
232
apt_task_method_f
terminate
;
233
/** Virtual run method*/
234
apt_task_method_f
run
;
235
236
/** Virtual signal_msg method */
237
apt_bool_t
(*
signal_msg
)(
apt_task_t
*task,
apt_task_msg_t
*msg);
238
/** Virtual process_msg method */
239
apt_bool_t
(*
process_msg
)(
apt_task_t
*task,
apt_task_msg_t
*msg);
240
241
/** Virtual process_start method */
242
apt_bool_t
(*
process_start
)(
apt_task_t
*task);
243
/** Virtual process_terminate method */
244
apt_bool_t
(*
process_terminate
)(
apt_task_t
*task);
245
246
/** Virtual pre-run event handler */
247
apt_task_event_f
on_pre_run
;
248
/** Virtual post-run event handler */
249
apt_task_event_f
on_post_run
;
250
/** Virtual start-complete event handler */
251
apt_task_event_f
on_start_complete
;
252
/** Virtual terminate-complete event handler */
253
apt_task_event_f
on_terminate_complete
;
254
/** Virtual take-offline-complete event handler */
255
apt_task_event_f
on_offline_complete
;
256
/** Virtual bring-online-complete event handler */
257
apt_task_event_f
on_online_complete
;
258
};
259
260
APT_END_EXTERN_C
261
262
#endif
/* APT_TASK_H */
Generated on Mon Feb 2 2015 19:41:38 for UniMRCP by
1.8.3.1