UniMRCP
1.2.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 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
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
* 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
*/
78
APT_DECLARE
(
apt_bool_t
)
apt_task_terminate
(
apt_task_t
*task,
apt_bool_t
wait_till_complete);
79
80
/**
81
* Start child tasks.
82
* @param task the parent task
83
*/
84
APT_DECLARE
(
apt_bool_t
)
apt_task_child_start
(
apt_task_t
*task);
85
86
/**
87
* Terminate child tasks.
88
* @param task the parent task
89
*/
90
APT_DECLARE
(
apt_bool_t
)
apt_task_child_terminate
(
apt_task_t
*task);
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
* Get parent (master) task.
127
* @param task the task to get parent from
128
*/
129
APT_DECLARE
(
apt_task_t
*)
apt_task_parent_get
(const
apt_task_t
*task);
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
*/
147
APT_DECLARE
(
apt_task_vtable_t
*)
apt_task_vtable_get
(
apt_task_t
*task);
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
*/
167
APT_DECLARE
(
void
)
apt_task_auto_ready_set
(
apt_task_t
*task,
apt_bool_t
auto_ready);
168
169
/**
170
* Explicitly indicate task is ready to process messages.
171
* @param task the task
172
*/
173
APT_DECLARE
(
apt_bool_t
)
apt_task_ready
(
apt_task_t
*task);
174
175
/**
176
* Get the running flag.
177
* @param task the task
178
*/
179
APT_DECLARE
(
apt_bool_t
*)
apt_task_running_flag_get
(
apt_task_t
*task);
180
181
/**
182
* Add start request.
183
* @param task the task
184
*/
185
APT_DECLARE
(
apt_bool_t
)
apt_task_start_request_add
(
apt_task_t
*task);
186
187
/**
188
* Remove start request.
189
* @param task the task
190
*/
191
APT_DECLARE
(
apt_bool_t
)
apt_task_start_request_remove
(
apt_task_t
*task);
192
193
/**
194
* Add termination request.
195
* @param task the task
196
*/
197
APT_DECLARE
(
apt_bool_t
)
apt_task_terminate_request_add
(
apt_task_t
*task);
198
199
/**
200
* Remove termination request.
201
* @param task the task
202
*/
203
APT_DECLARE
(
apt_bool_t
)
apt_task_terminate_request_remove
(
apt_task_t
*task);
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 */
213
struct
apt_task_vtable_t
{
214
/** Virtual destroy method */
215
apt_task_method_f
destroy
;
216
/** Virtual start method*/
217
apt_task_method_f
start
;
218
/** Virtual terminate method */
219
apt_task_method_f
terminate
;
220
/** Virtual run method*/
221
apt_task_method_f
run
;
222
223
/** Virtual signal method */
224
apt_bool_t
(*
signal_msg
)(
apt_task_t
*task,
apt_task_msg_t
*msg);
225
/** Virtual process method */
226
apt_bool_t
(*
process_msg
)(
apt_task_t
*task,
apt_task_msg_t
*msg);
227
228
/** Virtual pre-run event handler */
229
apt_task_event_f
on_pre_run
;
230
/** Virtual post-run event handler */
231
apt_task_event_f
on_post_run
;
232
/** Virtual start-request event handler */
233
apt_task_event_f
on_start_request
;
234
/** Virtual start-complete event handler */
235
apt_task_event_f
on_start_complete
;
236
/** Virtual terminate-request event handler */
237
apt_task_event_f
on_terminate_request
;
238
/** Virtual terminate-complete event handler */
239
apt_task_event_f
on_terminate_complete
;
240
};
241
242
APT_END_EXTERN_C
243
244
#endif
/* APT_TASK_H */
Generated on Sun Jul 6 2014 22:12:45 for UniMRCP by
1.8.3.1