00001 /* 00002 * Copyright 2004,2005 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef AXIS2_THREAD_H 00018 #define AXIS2_THREAD_H 00019 00020 00026 #include <axis2_allocator.h> 00027 #include <axis2_utils_defines.h> 00028 #include <axis2_error.h> 00029 00030 00031 00032 #ifdef __cplusplus 00033 extern "C" 00034 { 00035 #endif 00036 00047 /*#define AXIS2_THREAD_FUNC*/ 00048 00050 typedef struct axis2_thread_t axis2_thread_t; 00051 00053 typedef struct axis2_threadattr_t axis2_threadattr_t; 00054 00056 typedef struct axis2_thread_once_t axis2_thread_once_t; 00057 00061 typedef void *(AXIS2_THREAD_FUNC *axis2_thread_start_t)(axis2_thread_t*, void*); 00062 00064 typedef struct axis2_threadkey_t axis2_threadkey_t; 00065 00066 /* Thread Function definitions */ 00067 00073 AXIS2_EXTERN axis2_threadattr_t* AXIS2_CALL 00074 axis2_threadattr_create(axis2_allocator_t *allocator); 00075 00082 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00083 axis2_threadattr_detach_set(axis2_threadattr_t *attr, axis2_bool_t detached); 00084 00091 AXIS2_EXTERN axis2_bool_t AXIS2_CALL 00092 axis2_threadattr_is_detach(axis2_threadattr_t *attr, axis2_allocator_t *allocator); 00093 00094 00103 AXIS2_EXTERN axis2_thread_t* AXIS2_CALL 00104 axis2_thread_create(axis2_allocator_t *allocator, axis2_threadattr_t *attr, 00105 axis2_thread_start_t func, void *data); 00106 00112 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00113 axis2_thread_exit(axis2_thread_t *thd, axis2_allocator_t *allocator); 00114 00120 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00121 axis2_thread_join(axis2_thread_t *thd); 00122 00126 AXIS2_EXTERN void AXIS2_CALL 00127 axis2_thread_yield(); 00128 00134 AXIS2_EXTERN axis2_thread_once_t* AXIS2_CALL 00135 axis2_thread_once_init(axis2_allocator_t *allocator); 00136 00147 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00148 axis2_thread_once(axis2_thread_once_t *control, void (*func)(void)); 00149 00155 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00156 axis2_thread_detach(axis2_thread_t *thd); 00157 00158 /*************************Thread locking functions*****************************/ 00159 00161 typedef struct axis2_thread_mutex_t axis2_thread_mutex_t; 00162 00163 #define AXIS2_THREAD_MUTEX_DEFAULT 0x0 00164 #define AXIS2_THREAD_MUTEX_NESTED 0x1 00165 #define AXIS2_THREAD_MUTEX_UNNESTED 0x2 00174 AXIS2_EXTERN axis2_thread_mutex_t * AXIS2_CALL 00175 axis2_thread_mutex_create(axis2_allocator_t *allocator, unsigned int flags); 00181 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00182 axis2_thread_mutex_lock(axis2_thread_mutex_t *mutex); 00183 00189 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00190 axis2_thread_mutex_trylock(axis2_thread_mutex_t *mutex); 00191 00196 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00197 axis2_thread_mutex_unlock(axis2_thread_mutex_t *mutex); 00198 00203 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00204 axis2_thread_mutex_destroy(axis2_thread_mutex_t *mutex); 00205 00207 #ifdef __cplusplus 00208 } 00209 #endif 00210 00211 #endif /* AXIS2_THREAD_H */