globus_common 18.13
Loading...
Searching...
No Matches
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
18
19#if !defined GLOBUS_THREAD_WINDOWS_H
20#define GLOBUS_THREAD_WINDOWS_H
21
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
33typedef void * (*globus_thread_func_t)(void *user_arg);
34typedef void (*globus_thread_key_destructor_func_t)(void *);
35
36typedef struct globus_thread_key_s
37{
38 DWORD TLSIndex;
39 globus_thread_key_destructor_func_t destructorFunction;
41
42typedef 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
51typedef unsigned long globus_thread_t;
52
53typedef struct __globus_threadattr_t
54{
55 void * threadAttribute;
57
58typedef struct _globus_mutexattr_t
59{
60 LPSECURITY_ATTRIBUTES securityAttributes;
62
63typedef HANDLE globus_mutex_t;
64
65typedef struct _globus_condattr_t
66{
67 LPSECURITY_ATTRIBUTES securityAttributes;
69
70typedef struct _globus_cond_t
71{
72 HANDLE events[2];
73 int numberOfWaiters;
75
76/* typedef DWORD globus_abstime_t; */
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
82/* API calls */
83extern int globus_thread_create(globus_thread_t *thread,
85 globus_thread_func_t func,
86 void *user_arg);
87extern void globus_thread_exit(void *status);
88
89#define globus_macro_i_am_only_thread() GLOBUS_FALSE
90
91extern int globus_threadattr_init(globus_threadattr_t *attr);
92extern int globus_threadattr_destroy(globus_threadattr_t *attr);
93
98 void *value);
102 globus_thread_t t2);
103extern int globus_thread_once(globus_thread_once_t *once_control,
104 void (*init_routine)(void));
105extern void globus_thread_yield(void);
106
108
111extern int globus_mutex_init(globus_mutex_t *mutex,
112 globus_mutexattr_t *attr);
113extern int globus_mutex_destroy(globus_mutex_t *mutex);
114extern int globus_mutex_lock(globus_mutex_t *mutex);
115extern int globus_mutex_trylock(globus_mutex_t *mutex);
116extern int globus_mutex_unlock(globus_mutex_t *mutex);
117
118extern int globus_condattr_init (globus_condattr_t *attr);
120extern int globus_cond_init(globus_cond_t *cond,
121 globus_condattr_t *attr);
122extern int globus_cond_destroy(globus_cond_t *cond);
123extern int globus_cond_wait(globus_cond_t *cond,
124 globus_mutex_t *mutex);
125extern int globus_cond_timedwait(globus_cond_t *cond,
126 globus_mutex_t *mutex,
127 globus_abstime_t * abstime);
128extern int globus_cond_timedwait_rel( globus_cond_t *cv,
129 globus_mutex_t *mut,
130 long milliseconds );
131extern int globus_cond_signal(globus_cond_t *cond);
132extern int globus_cond_broadcast(globus_cond_t *cond);
133extern int globus_thread_cancel(globus_thread_t thread);
134
135
136
137/******************************************************************************
138 Module definition
139******************************************************************************/
140
141extern int globus_i_thread_pre_activate();
142
143extern 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 */
Include System Headers.
Linked List.
Reference Counting Module Activation and Deactivation.
Time Types and Macros.
int globus_bool_t
Boolean type.
Definition globus_types.h:93
int globus_cond_signal(globus_cond_t *cond)
Signal a condition to a thread.
Definition globus_thread.c:661
int globus_condattr_destroy(globus_condattr_t *attr)
Destroy a condition attribute.
Definition globus_thread.c:852
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_condattr_init(globus_condattr_t *attr)
Initialize a condition variable attribute.
Definition globus_thread.c:814
int globus_cond_broadcast(globus_cond_t *cond)
Signal a condition to multiple threads.
Definition globus_thread.c:697
int globus_cond_destroy(globus_cond_t *cond)
Destroy a condition variable.
Definition globus_thread.c:526
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_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
struct globus_list globus_list_t
List data type.
int globus_mutex_lock(globus_mutex_t *mutex)
Lock a mutex.
Definition globus_thread.c:347
int globus_mutex_init(globus_mutex_t *mutex, globus_mutexattr_t *attr)
Initialize a mutex.
Definition globus_thread.c:267
int globus_mutex_trylock(globus_mutex_t *mutex)
Lock a mutex if it is not locked.
Definition globus_thread.c:431
int globus_mutex_unlock(globus_mutex_t *mutex)
Unlock a mutex.
Definition globus_thread.c:388
int globus_mutex_destroy(globus_mutex_t *mutex)
Destroy a mutex.
Definition globus_thread.c:305
int globus_mutexattr_destroy(globus_mutexattr_t *attr)
Destroy a mutex attribute.
Definition globus_thread.c:775
int globus_mutexattr_init(globus_mutexattr_t *attr)
Initialize a mutex attribute.
Definition globus_thread.c:737
int globus_thread_key_delete(globus_thread_key_t key)
Delete a thread-local storage key.
Definition globus_thread.c:1123
void * globus_thread_getspecific(globus_thread_key_t key)
Get a thread-specific data value.
Definition globus_thread.c:1269
int globus_thread_setspecific(globus_thread_key_t key, void *value)
Set a thread-specific data value.
Definition globus_thread.c:1331
int globus_thread_key_create(globus_thread_key_t *key, globus_thread_key_destructor_func_t destructor_func)
Create a key for thread-specific storage.
Definition globus_thread.c:1081
int globus_thread_once(globus_thread_once_t *once_control, void(*init_routine)(void))
Execute a function one time.
Definition globus_thread.c:1206
globus_thread_t globus_thread_self(void)
Determine the current thread's ID.
Definition globus_thread.c:1513
int globus_thread_equal(globus_thread_t t1, globus_thread_t t2)
Check whether thread identifiers match.
Definition globus_thread.c:1552
int globus_thread_cancel(globus_thread_t thread)
Cancel a thread.
Definition globus_thread.c:1709
void globus_thread_yield(void)
Yield execution to another thread.
Definition globus_thread.c:1362
globus_bool_t globus_i_am_only_thread(void)
Determine if threads are supported.
Definition globus_thread.c:1614
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
void globus_thread_exit(void *status)
Terminate the current thread.
Definition globus_thread.c:1386
void(* globus_thread_key_destructor_func_t)(void *value)
Thread-specific data destructor.
Definition globus_thread.h:195
Condition variable.
Definition globus_thread.h:125
Condition variable attribute.
Definition globus_thread.h:172
Mutex.
Definition globus_thread.h:108
Mutex attribute.
Definition globus_thread.h:152
Thread-specific data key.
Definition globus_thread.h:202
Thread ID.
Definition globus_thread.h:72
Thread attributes.
Definition globus_thread.h:89