00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef AXIS2_THREAD_POOL_H
00019 #define AXIS2_THREAD_POOL_H
00020
00026 #include <axis2_utils_defines.h>
00027 #include <axis2_allocator.h>
00028 #include <axis2_thread.h>
00029
00030 #ifdef __cplusplus
00031 extern "C"
00032 {
00033 #endif
00034
00041 typedef struct axis2_thread_pool_ops axis2_thread_pool_ops_t;
00042 typedef struct axis2_thread_pool axis2_thread_pool_t;
00043 struct axis2_env;
00044
00050 struct axis2_thread_pool_ops
00051 {
00058 axis2_thread_t * (AXIS2_CALL *
00059 get_thread) (axis2_thread_pool_t *pool,
00060 axis2_thread_start_t func,
00061 void *data);
00067 axis2_status_t (AXIS2_CALL *
00068 join_thread) (axis2_thread_pool_t *pool,
00069 axis2_thread_t *thd);
00075 axis2_status_t (AXIS2_CALL *
00076 exit_thread) (axis2_thread_pool_t *pool,
00077 axis2_thread_t *thd);
00083 axis2_status_t (AXIS2_CALL *
00084 thread_detach) (axis2_thread_pool_t *pool,
00085 axis2_thread_t *thd);
00090 axis2_status_t (AXIS2_CALL *
00091 free) (axis2_thread_pool_t *pool);
00092 };
00093
00098 struct axis2_thread_pool
00099 {
00100 axis2_thread_pool_ops_t *ops;
00101 };
00107 AXIS2_EXTERN axis2_thread_pool_t * AXIS2_CALL axis2_thread_pool_init(
00108 axis2_allocator_t *allocator);
00109
00114 AXIS2_EXTERN struct axis2_env * AXIS2_CALL
00115 axis2_init_thread_env(const struct axis2_env *system_env);
00116
00121 AXIS2_EXTERN void AXIS2_CALL
00122 axis2_free_thread_env(struct axis2_env *thread_env);
00123
00124 #define AXIS2_THREAD_POOL_GET_THREAD(thread_pool, func, data) \
00125 ((thread_pool)->ops->get_thread(thread_pool, func, data))
00126
00127 #define AXIS2_THREAD_POOL_JOIN_THREAD(thread_pool, thd) \
00128 ((thread_pool)->ops->join_thread(thread_pool, thd))
00129
00130 #define AXIS2_THREAD_POOL_EXIT_THREAD(thread_pool, thd) \
00131 ((thread_pool)->ops->exit_thread(thread_pool, thd))
00132
00133 #define AXIS2_THREAD_POOL_THREAD_DETACH(thread_pool, thd) \
00134 ((thread_pool)->ops->thread_detach(thread_pool, thd))
00135
00136 #define AXIS2_THREAD_POOL_FREE(thread_pool) \
00137 ((thread_pool)->ops->free(thread_pool))
00138
00141 #ifdef __cplusplus
00142 }
00143 #endif
00144
00145 #endif