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 00046 /*#define AXIS2_THREAD_FUNC*/ 00047 00049 typedef struct axis2_thread_t axis2_thread_t; 00050 00052 typedef struct axis2_threadattr_t axis2_threadattr_t; 00053 00055 typedef struct axis2_thread_once_t axis2_thread_once_t; 00056 00060 typedef void *(AXIS2_THREAD_FUNC *axis2_thread_start_t)(axis2_thread_t*, void*); 00061 00063 typedef struct axis2_threadkey_t axis2_threadkey_t; 00064 00065 /* Thread Function definitions */ 00066 00072 AXIS2_EXTERN axis2_threadattr_t* AXIS2_CALL 00073 axis2_threadattr_create(axis2_allocator_t *allocator); 00074 00081 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00082 axis2_threadattr_detach_set(axis2_threadattr_t *attr, axis2_bool_t detached); 00083 00090 AXIS2_EXTERN axis2_bool_t AXIS2_CALL 00091 axis2_threadattr_is_detach(axis2_threadattr_t *attr, axis2_allocator_t *allocator); 00092 00093 00102 AXIS2_EXTERN axis2_thread_t* AXIS2_CALL 00103 axis2_thread_create(axis2_allocator_t *allocator, axis2_threadattr_t *attr, 00104 axis2_thread_start_t func, void *data); 00105 00111 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00112 axis2_thread_exit(axis2_thread_t *thd, axis2_allocator_t *allocator); 00113 00119 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00120 axis2_thread_join(axis2_thread_t *thd); 00121 00125 AXIS2_EXTERN void AXIS2_CALL 00126 axis2_thread_yield(); 00127 00133 AXIS2_EXTERN axis2_thread_once_t* AXIS2_CALL 00134 axis2_thread_once_init(axis2_allocator_t *allocator); 00135 00146 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00147 axis2_thread_once(axis2_thread_once_t *control, void (*func)(void)); 00148 00154 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00155 axis2_thread_detach(axis2_thread_t *thd); 00156 00157 /*************************Thread locking functions*****************************/ 00158 00160 typedef struct axis2_thread_mutex_t axis2_thread_mutex_t; 00161 00162 #define AXIS2_THREAD_MUTEX_DEFAULT 0x0 00163 #define AXIS2_THREAD_MUTEX_NESTED 0x1 00164 #define AXIS2_THREAD_MUTEX_UNNESTED 0x2 00173 AXIS2_EXTERN axis2_thread_mutex_t * AXIS2_CALL 00174 axis2_thread_mutex_create(axis2_allocator_t *allocator, unsigned int flags); 00180 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00181 axis2_thread_mutex_lock(axis2_thread_mutex_t *mutex); 00182 00188 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00189 axis2_thread_mutex_trylock(axis2_thread_mutex_t *mutex); 00190 00195 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00196 axis2_thread_mutex_unlock(axis2_thread_mutex_t *mutex); 00197 00202 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00203 axis2_thread_mutex_destroy(axis2_thread_mutex_t *mutex); 00204 00206 #ifdef __cplusplus 00207 } 00208 #endif 00209 00210 #endif /* AXIS2_THREAD_H */