00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef AXIS2_THREAD_H 00019 #define AXIS2_THREAD_H 00020 00021 00027 #include <axis2_allocator.h> 00028 #include <axis2_utils_defines.h> 00029 #include <axis2_error.h> 00030 00031 00032 00033 #ifdef __cplusplus 00034 extern "C" 00035 { 00036 #endif 00037 00048 /*#define AXIS2_THREAD_FUNC*/ 00049 00051 typedef struct axis2_thread_t axis2_thread_t; 00052 00054 typedef struct axis2_threadattr_t axis2_threadattr_t; 00055 00057 typedef struct axis2_thread_once_t axis2_thread_once_t; 00058 00062 typedef void *(AXIS2_THREAD_FUNC *axis2_thread_start_t)(axis2_thread_t*, void*); 00063 00065 typedef struct axis2_threadkey_t axis2_threadkey_t; 00066 00067 /* Thread Function definitions */ 00068 00074 AXIS2_EXTERN axis2_threadattr_t* AXIS2_CALL 00075 axis2_threadattr_create(axis2_allocator_t *allocator); 00076 00083 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00084 axis2_threadattr_detach_set(axis2_threadattr_t *attr, axis2_bool_t detached); 00085 00092 AXIS2_EXTERN axis2_bool_t AXIS2_CALL 00093 axis2_threadattr_is_detach(axis2_threadattr_t *attr, axis2_allocator_t *allocator); 00094 00095 00104 AXIS2_EXTERN axis2_thread_t* AXIS2_CALL 00105 axis2_thread_create(axis2_allocator_t *allocator, axis2_threadattr_t *attr, 00106 axis2_thread_start_t func, void *data); 00107 00113 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00114 axis2_thread_exit(axis2_thread_t *thd, axis2_allocator_t *allocator); 00115 00121 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00122 axis2_thread_join(axis2_thread_t *thd); 00123 00127 AXIS2_EXTERN void AXIS2_CALL 00128 axis2_thread_yield(); 00129 00135 AXIS2_EXTERN axis2_thread_once_t* AXIS2_CALL 00136 axis2_thread_once_init(axis2_allocator_t *allocator); 00137 00148 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00149 axis2_thread_once(axis2_thread_once_t *control, void (*func)(void)); 00150 00156 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00157 axis2_thread_detach(axis2_thread_t *thd); 00158 00159 /*************************Thread locking functions*****************************/ 00160 00162 typedef struct axis2_thread_mutex_t axis2_thread_mutex_t; 00163 00164 #define AXIS2_THREAD_MUTEX_DEFAULT 0x0 00165 #define AXIS2_THREAD_MUTEX_NESTED 0x1 00166 #define AXIS2_THREAD_MUTEX_UNNESTED 0x2 00175 AXIS2_EXTERN axis2_thread_mutex_t * AXIS2_CALL 00176 axis2_thread_mutex_create(axis2_allocator_t *allocator, unsigned int flags); 00182 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00183 axis2_thread_mutex_lock(axis2_thread_mutex_t *mutex); 00184 00190 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00191 axis2_thread_mutex_trylock(axis2_thread_mutex_t *mutex); 00192 00197 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00198 axis2_thread_mutex_unlock(axis2_thread_mutex_t *mutex); 00199 00204 AXIS2_EXTERN axis2_status_t AXIS2_CALL 00205 axis2_thread_mutex_destroy(axis2_thread_mutex_t *mutex); 00206 00208 #ifdef __cplusplus 00209 } 00210 #endif 00211 00212 #endif /* AXIS2_THREAD_H */