00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef APT_TASK_H
00020 #define APT_TASK_H
00021
00022
00023
00024
00025
00026
00027 #include "apt.h"
00028 #include "apt_task_msg.h"
00029
00030 APT_BEGIN_EXTERN_C
00031
00032
00033 typedef struct apt_task_t apt_task_t;
00034
00035 typedef struct apt_task_vtable_t apt_task_vtable_t;
00036
00037 typedef apt_bool_t (*apt_task_method_f)(apt_task_t *task);
00038
00039 typedef void (*apt_task_event_f)(apt_task_t *task);
00040
00041
00042
00043
00044
00045
00046
00047
00048 APT_DECLARE(apt_task_t*) apt_task_create(
00049 void *obj,
00050 apt_task_msg_pool_t *msg_pool,
00051 apr_pool_t *pool);
00052
00053
00054
00055
00056
00057 APT_DECLARE(apt_bool_t) apt_task_destroy(apt_task_t *task);
00058
00059
00060
00061
00062
00063
00064 APT_DECLARE(apt_bool_t) apt_task_add(apt_task_t *task, apt_task_t *child_task);
00065
00066
00067
00068
00069
00070 APT_DECLARE(apt_bool_t) apt_task_start(apt_task_t *task);
00071
00072
00073
00074
00075
00076
00077
00078 APT_DECLARE(apt_bool_t) apt_task_terminate(apt_task_t *task, apt_bool_t wait_till_complete);
00079
00080
00081
00082
00083
00084 APT_DECLARE(apt_bool_t) apt_task_child_start(apt_task_t *task);
00085
00086
00087
00088
00089
00090 APT_DECLARE(apt_bool_t) apt_task_child_terminate(apt_task_t *task);
00091
00092
00093
00094
00095
00096 APT_DECLARE(apt_bool_t) apt_task_wait_till_complete(apt_task_t *task);
00097
00098
00099
00100
00101
00102 APT_DECLARE(apt_task_msg_t*) apt_task_msg_get(apt_task_t *task);
00103
00104
00105
00106
00107
00108
00109 APT_DECLARE(apt_bool_t) apt_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg);
00110
00111
00112
00113
00114
00115
00116 APT_DECLARE(apt_bool_t) apt_task_msg_parent_signal(apt_task_t *task, apt_task_msg_t *msg);
00117
00118
00119
00120
00121
00122
00123 APT_DECLARE(apt_bool_t) apt_task_msg_process(apt_task_t *task, apt_task_msg_t *msg);
00124
00125
00126
00127
00128
00129 APT_DECLARE(apt_task_t*) apt_task_parent_get(const apt_task_t *task);
00130
00131
00132
00133
00134
00135 APT_DECLARE(apr_pool_t*) apt_task_pool_get(const apt_task_t *task);
00136
00137
00138
00139
00140
00141 APT_DECLARE(void*) apt_task_object_get(const apt_task_t *task);
00142
00143
00144
00145
00146
00147 APT_DECLARE(apt_task_vtable_t*) apt_task_vtable_get(apt_task_t *task);
00148
00149
00150
00151
00152
00153
00154 APT_DECLARE(void) apt_task_name_set(apt_task_t *task, const char *name);
00155
00156
00157
00158
00159
00160 APT_DECLARE(const char*) apt_task_name_get(const apt_task_t *task);
00161
00162
00163
00164
00165
00166
00167 APT_DECLARE(void) apt_task_auto_ready_set(apt_task_t *task, apt_bool_t auto_ready);
00168
00169
00170
00171
00172
00173 APT_DECLARE(apt_bool_t) apt_task_ready(apt_task_t *task);
00174
00175
00176
00177
00178
00179 APT_DECLARE(apt_bool_t*) apt_task_running_flag_get(apt_task_t *task);
00180
00181
00182
00183
00184
00185 APT_DECLARE(apt_bool_t) apt_task_start_request_add(apt_task_t *task);
00186
00187
00188
00189
00190
00191 APT_DECLARE(apt_bool_t) apt_task_start_request_remove(apt_task_t *task);
00192
00193
00194
00195
00196
00197 APT_DECLARE(apt_bool_t) apt_task_terminate_request_add(apt_task_t *task);
00198
00199
00200
00201
00202
00203 APT_DECLARE(apt_bool_t) apt_task_terminate_request_remove(apt_task_t *task);
00204
00205
00206
00207
00208
00209 APT_DECLARE(void) apt_task_delay(apr_size_t msec);
00210
00211
00212
00213 struct apt_task_vtable_t {
00214
00215 apt_task_method_f destroy;
00216
00217 apt_task_method_f start;
00218
00219 apt_task_method_f terminate;
00220
00221 apt_task_method_f run;
00222
00223
00224 apt_bool_t (*signal_msg)(apt_task_t *task, apt_task_msg_t *msg);
00225
00226 apt_bool_t (*process_msg)(apt_task_t *task, apt_task_msg_t *msg);
00227
00228
00229 apt_task_event_f on_pre_run;
00230
00231 apt_task_event_f on_post_run;
00232
00233 apt_task_event_f on_start_request;
00234
00235 apt_task_event_f on_start_complete;
00236
00237 apt_task_event_f on_terminate_request;
00238
00239 apt_task_event_f on_terminate_complete;
00240 };
00241
00242 APT_END_EXTERN_C
00243
00244 #endif