globus_thread_windows.h

00001 /*
00002  * Copyright 1999-2006 University of Chicago
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 
00019 #if !defined GLOBUS_THREAD_WINDOWS_H
00020 #define GLOBUS_THREAD_WINDOWS_H
00021 
00022 #include "globus_common_include.h"
00023 #include "globus_module.h"
00024 #include "globus_time.h"
00025 #include "globus_list.h"
00026 
00027 #define GLOBUS_NULL_POINTER_PARAMETER -1
00028 #define globus_thread_once_t int
00029 #define GLOBUS_THREAD_ONCE_INIT 0
00030 #define GLOBUS_THREAD_ONCE_CALLED 1
00031 
00032 
00033 typedef void * (*globus_thread_func_t)(void *user_arg); 
00034 typedef void (*globus_thread_key_destructor_func_t)(void *); 
00035 
00036 typedef struct globus_thread_key_s
00037 {
00038     DWORD TLSIndex;
00039     globus_thread_key_destructor_func_t destructorFunction;
00040 } globus_thread_key_t;
00041 
00042 typedef struct globus_i_thread_t
00043 {
00044         unsigned long threadID;
00045         UserFunctionInfo userFunctionInfo;
00046         // list of keys associated with this thread 
00047         // that have destructor functions
00048         globus_list_t * dataDestructionKeyList;
00049 } globus_i_thread_t;
00050 
00051 typedef unsigned long globus_thread_t;
00052 
00053 typedef struct __globus_threadattr_t
00054 {
00055         void * threadAttribute;
00056 } globus_threadattr_t;
00057 
00058 typedef struct _globus_mutexattr_t
00059 {
00060         LPSECURITY_ATTRIBUTES securityAttributes;
00061 } globus_mutexattr_t;
00062 
00063 typedef HANDLE globus_mutex_t;
00064 
00065 typedef struct _globus_condattr_t
00066 {
00067         LPSECURITY_ATTRIBUTES securityAttributes;
00068 } globus_condattr_t;
00069 
00070 typedef struct _globus_cond_t
00071 {
00072         HANDLE events[2];
00073         int numberOfWaiters;
00074 } globus_cond_t;
00075 
00076 /* typedef DWORD globus_abstime_t; */
00077 
00078 #ifdef __cplusplus
00079 extern "C" {
00080 #endif
00081 
00082 /* API calls */
00083 extern int      globus_thread_create(globus_thread_t *thread,
00084                                      globus_threadattr_t *attr,
00085                                      globus_thread_func_t func,
00086                                      void *user_arg);
00087 extern void     globus_thread_exit(void *status);
00088 
00089 #define globus_macro_i_am_only_thread() GLOBUS_FALSE
00090 
00091 extern int              globus_threadattr_init(globus_threadattr_t *attr);
00092 extern int              globus_threadattr_destroy(globus_threadattr_t *attr);
00093 
00094 extern int              globus_thread_key_create(globus_thread_key_t *key,
00095                                    globus_thread_key_destructor_func_t destructor_func);
00096 extern int              globus_thread_key_delete(globus_thread_key_t key);
00097 extern int              globus_thread_setspecific(globus_thread_key_t key,
00098                                                   void *value);
00099 extern void *           globus_thread_getspecific(globus_thread_key_t key);
00100 extern globus_thread_t  globus_thread_self(void);
00101 extern int              globus_thread_equal(globus_thread_t t1,
00102                                             globus_thread_t t2);
00103 extern int              globus_thread_once(globus_thread_once_t *once_control,
00104                                            void (*init_routine)(void));
00105 extern void             globus_thread_yield(void);
00106 
00107 extern globus_bool_t    globus_i_am_only_thread(void);
00108 
00109 extern int              globus_mutexattr_init(globus_mutexattr_t *attr);
00110 extern int              globus_mutexattr_destroy(globus_mutexattr_t *attr);
00111 extern int              globus_mutex_init(globus_mutex_t *mutex,
00112                                           globus_mutexattr_t *attr);
00113 extern int              globus_mutex_destroy(globus_mutex_t *mutex);
00114 extern int              globus_mutex_lock(globus_mutex_t *mutex);
00115 extern int              globus_mutex_trylock(globus_mutex_t *mutex);
00116 extern int              globus_mutex_unlock(globus_mutex_t *mutex);
00117 
00118 extern int              globus_condattr_init (globus_condattr_t *attr);
00119 extern int              globus_condattr_destroy (globus_condattr_t *attr);
00120 extern int              globus_cond_init(globus_cond_t *cond,
00121                                          globus_condattr_t *attr);
00122 extern int              globus_cond_destroy(globus_cond_t *cond);
00123 extern int              globus_cond_wait(globus_cond_t *cond,
00124                                          globus_mutex_t *mutex);
00125 extern int              globus_cond_timedwait(globus_cond_t *cond,
00126                                          globus_mutex_t *mutex,
00127                                          globus_abstime_t * abstime);
00128 extern int              globus_cond_timedwait_rel( globus_cond_t *cv, 
00129                                          globus_mutex_t *mut,
00130                                          long milliseconds );
00131 extern int              globus_cond_signal(globus_cond_t *cond);
00132 extern int              globus_cond_broadcast(globus_cond_t *cond);
00133 extern int      globus_thread_cancel(globus_thread_t thread);
00134 
00135 
00136 
00137 /******************************************************************************
00138                                Module definition
00139 ******************************************************************************/
00140 
00141 extern int globus_i_thread_pre_activate();
00142 
00143 extern globus_module_descriptor_t globus_i_thread_module;
00144 
00145 #define GLOBUS_THREAD_MODULE (&globus_i_thread_module)
00146 
00147 #ifdef __cplusplus
00148 }
00149 #endif
00150 
00151 #endif /* GLOBUS_THREAD_WINDOWS_H */

Generated on 17 Mar 2017 for globus_common by  doxygen 1.4.7