Grid Community Toolkit  6.2.1653033972 (tag: v6.2.20220524)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_thread_windows.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
19 #if !defined GLOBUS_THREAD_WINDOWS_H
20 #define GLOBUS_THREAD_WINDOWS_H
21 
22 #include "globus_common_include.h"
23 #include "globus_module.h"
24 #include "globus_time.h"
25 #include "globus_list.h"
26 
27 #define GLOBUS_NULL_POINTER_PARAMETER -1
28 #define globus_thread_once_t int
29 #define GLOBUS_THREAD_ONCE_INIT 0
30 #define GLOBUS_THREAD_ONCE_CALLED 1
31 
32 
33 typedef void * (*globus_thread_func_t)(void *user_arg);
34 typedef void (*globus_thread_key_destructor_func_t)(void *);
35 
36 typedef struct globus_thread_key_s
37 {
38  DWORD TLSIndex;
39  globus_thread_key_destructor_func_t destructorFunction;
41 
42 typedef struct globus_i_thread_t
43 {
44  unsigned long threadID;
45  UserFunctionInfo userFunctionInfo;
46  // list of keys associated with this thread
47  // that have destructor functions
48  globus_list_t * dataDestructionKeyList;
49 } globus_i_thread_t;
50 
51 typedef unsigned long globus_thread_t;
52 
53 typedef struct __globus_threadattr_t
54 {
55  void * threadAttribute;
57 
58 typedef struct _globus_mutexattr_t
59 {
60  LPSECURITY_ATTRIBUTES securityAttributes;
62 
63 typedef HANDLE globus_mutex_t;
64 
65 typedef struct _globus_condattr_t
66 {
67  LPSECURITY_ATTRIBUTES securityAttributes;
69 
70 typedef struct _globus_cond_t
71 {
72  HANDLE events[2];
73  int numberOfWaiters;
75 
76 /* typedef DWORD globus_abstime_t; */
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 /* API calls */
83 extern int globus_thread_create(globus_thread_t *thread,
84  globus_threadattr_t *attr,
85  globus_thread_func_t func,
86  void *user_arg);
87 extern void globus_thread_exit(void *status);
88 
89 #define globus_macro_i_am_only_thread() GLOBUS_FALSE
90 
91 extern int globus_threadattr_init(globus_threadattr_t *attr);
92 extern int globus_threadattr_destroy(globus_threadattr_t *attr);
93 
95  globus_thread_key_destructor_func_t destructor_func);
98  void *value);
102  globus_thread_t t2);
104  void (*init_routine)(void));
105 extern void globus_thread_yield(void);
106 
108 
109 extern int globus_mutexattr_init(globus_mutexattr_t *attr);
111 extern int globus_mutex_init(globus_mutex_t *mutex,
112  globus_mutexattr_t *attr);
113 extern int globus_mutex_destroy(globus_mutex_t *mutex);
114 extern int globus_mutex_lock(globus_mutex_t *mutex);
115 extern int globus_mutex_trylock(globus_mutex_t *mutex);
116 extern int globus_mutex_unlock(globus_mutex_t *mutex);
117 
118 extern int globus_condattr_init (globus_condattr_t *attr);
119 extern int globus_condattr_destroy (globus_condattr_t *attr);
120 extern int globus_cond_init(globus_cond_t *cond,
121  globus_condattr_t *attr);
122 extern int globus_cond_destroy(globus_cond_t *cond);
123 extern int globus_cond_wait(globus_cond_t *cond,
124  globus_mutex_t *mutex);
125 extern int globus_cond_timedwait(globus_cond_t *cond,
126  globus_mutex_t *mutex,
127  globus_abstime_t * abstime);
128 extern int globus_cond_timedwait_rel( globus_cond_t *cv,
129  globus_mutex_t *mut,
130  long milliseconds );
131 extern int globus_cond_signal(globus_cond_t *cond);
132 extern int globus_cond_broadcast(globus_cond_t *cond);
133 extern int globus_thread_cancel(globus_thread_t thread);
134 
135 
136 
137 /******************************************************************************
138  Module definition
139 ******************************************************************************/
140 
141 extern int globus_i_thread_pre_activate();
142 
143 extern globus_module_descriptor_t globus_i_thread_module;
144 
145 #define GLOBUS_THREAD_MODULE (&globus_i_thread_module)
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* GLOBUS_THREAD_WINDOWS_H */
Thread ID.
Definition: globus_thread.h:71
int globus_cond_timedwait(globus_cond_t *cond, globus_mutex_t *mutex, globus_abstime_t *abstime)
Wait for a condition to be signalled.
Definition: globus_thread.c:623
globus_bool_t globus_i_am_only_thread(void)
Determine if threads are supported.
Definition: globus_thread.c:1614
int globus_cond_broadcast(globus_cond_t *cond)
Signal a condition to multiple threads.
Definition: globus_thread.c:697
int globus_cond_wait(globus_cond_t *cond, globus_mutex_t *mutex)
Wait for a condition to be signalled.
Definition: globus_thread.c:571
int globus_mutexattr_destroy(globus_mutexattr_t *attr)
Destroy a mutex attribute.
Definition: globus_thread.c:775
int globus_thread_key_delete(globus_thread_key_t key)
Delete a thread-local storage key.
Definition: globus_thread.c:1123
int globus_cond_destroy(globus_cond_t *cond)
Destroy a condition variable.
Definition: globus_thread.c:526
globus_thread_once_t once_control
Definition: module.c:121
Thread attributes.
Definition: globus_thread.h:88
int globus_bool_t
Boolean type.
Definition: globus_types.h:93
Linked List.
int globus_mutex_destroy(globus_mutex_t *mutex)
Destroy a mutex.
Definition: globus_thread.c:305
void(* globus_thread_key_destructor_func_t)(void *value)
Thread-specific data destructor.
Definition: globus_thread.h:195
Reference Counting Module Activation and Deactivation.
int globus_mutex_init(globus_mutex_t *mutex, globus_mutexattr_t *attr)
Initialize a mutex.
Definition: globus_thread.c:267
void * globus_thread_getspecific(globus_thread_key_t key)
Get a thread-specific data value.
Definition: globus_thread.c:1269
int globus_cond_init(globus_cond_t *cond, globus_condattr_t *attr)
Initialize a condition variableThe globus_cond_init() function creates a condition variable that can ...
Definition: globus_thread.c:487
int globus_thread_setspecific(globus_thread_key_t key, void *value)
Set a thread-specific data value.
Definition: globus_thread.c:1331
List data type.
Definition: globus_list.h:44
Thread once structure.
Definition: globus_thread.h:226
Mutex.
Definition: globus_thread.h:107
int globus_mutexattr_init(globus_mutexattr_t *attr)
Initialize a mutex attribute.
Definition: globus_thread.c:737
globus_thread_t globus_thread_self(void)
Determine the current thread's ID.
Definition: globus_thread.c:1513
int globus_mutex_unlock(globus_mutex_t *mutex)
Unlock a mutex.
Definition: globus_thread.c:388
void globus_thread_yield(void)
Yield execution to another thread.
Definition: globus_thread.c:1362
Condition variable.
Definition: globus_thread.h:124
int globus_condattr_destroy(globus_condattr_t *cond_attr)
Destroy a condition attribute.
Definition: globus_thread.c:852
Condition variable attribute.
Definition: globus_thread.h:171
int globus_condattr_init(globus_condattr_t *cond_attr)
Initialize a condition variable attribute.
Definition: globus_thread.c:814
int globus_thread_once(globus_thread_once_t *once, void(*init_routine)(void))
Execute a function one time.
Definition: globus_thread.c:1206
Thread-specific data key.
Definition: globus_thread.h:201
void globus_thread_exit(void *value)
Terminate the current thread.
Definition: globus_thread.c:1386
int globus_thread_key_create(globus_thread_key_t *key, globus_thread_key_destructor_func_t destructor)
Create a key for thread-specific storage.
Definition: globus_thread.c:1081
int globus_thread_cancel(globus_thread_t thr)
Cancel a thread.
Definition: globus_thread.c:1709
int globus_mutex_lock(globus_mutex_t *mutex)
Lock a mutex.
Definition: globus_thread.c:347
globus_bool_t globus_thread_equal(globus_thread_t thread1, globus_thread_t thread2)
Check whether thread identifiers match.
Definition: globus_thread.c:1552
Time Types and Macros.
int globus_mutex_trylock(globus_mutex_t *mutex)
Lock a mutex if it is not locked.
Definition: globus_thread.c:431
int globus_thread_create(globus_thread_t *thread, globus_threadattr_t *attr, globus_thread_func_t func, void *user_arg)
Create a new thread.
Definition: globus_thread.c:998
int globus_cond_signal(globus_cond_t *cond)
Signal a condition to a thread.
Definition: globus_thread.c:661
Include System Headers.
Module Descriptor.
Definition: globus_module.h:71
Mutex attribute.
Definition: globus_thread.h:151