25 #if !defined(GLOBUS_THREAD_H) 26 #define GLOBUS_THREAD_H 1 32 #if !defined(_WIN32) || defined(__MINGW32__) 37 #if !defined(HAVE_PTHREAD) 38 #define HAVE_PTHREAD 1 40 #if defined __GNUC__ && defined __EXCEPTIONS 43 #define __EXCEPTIONS 1 51 #define HAVE_WINDOWS_THREADS 1 63 #define GLOBUS_THREAD_MODEL_NONE "none" 64 #define GLOBUS_THREAD_MODEL_PTHREADS "pthread" 65 #define GLOBUS_THREAD_MODEL_WINDOWS "windows" 77 #if HAVE_WINDOWS_THREADS 92 pthread_attr_t pthread;
94 #if HAVE_WINDOWS_THREADS 101 typedef void * (*globus_thread_func_t)(
void *);
111 pthread_mutex_t pthread;
113 #if HAVE_WINDOWS_THREADS 128 struct globus_cond_pthread_s
135 #if HAVE_WINDOWS_THREADS 136 struct globus_cond_windows_s
155 pthread_mutexattr_t pthread;
157 #if HAVE_WINDOWS_THREADS 158 struct globus_mutexattr_windows_s
160 LPSECURITY_ATTRIBUTES securityAttributes;
175 struct globus_condattr_pthread_s
177 pthread_condattr_t attr;
181 #if HAVE_WINDOWS_THREADS 182 struct globus_condattr_windows_s
184 LPSECURITY_ATTRIBUTES securityAttributes;
205 pthread_key_t pthread;
207 #if HAVE_WINDOWS_THREADS 208 struct globus_thread_key_windows_s
230 pthread_once_t pthread;
232 #if HAVE_WINDOWS_THREADS 247 # define GLOBUS_THREAD_ONCE_INIT { .pthread = PTHREAD_ONCE_INIT } 248 #elif HAVE_WINDOWS_THREADS 249 # define GLOBUS_THREAD_ONCE_INIT { .windows = 0 } 251 # define GLOBUS_THREAD_ONCE_INIT { .none = 0 } 297 globus_abstime_t * abstime);
329 globus_thread_func_t func,
353 void (*init_routine)(
void));
361 const sigset_t * newmask,
388 void * (*func)(
void *),
390 void (*cleanup_func)(
void *),
410 #define GLOBUS_THREAD_CANCEL_DISABLE 0 416 #define GLOBUS_THREAD_CANCEL_ENABLE 1 420 globus_i_thread_pre_activate();
430 #define GLOBUS_THREAD_MODULE (&globus_i_thread_module) 457 void (*thread_yield)(void);
458 void (*thread_exit)(
void *value);
459 int (*thread_sigmask)(
int how,
const sigset_t *newmask, sigset_t *oldmask);
461 int (*thread_setcancelstate)(
int state,
int *oldstate);
462 void (*thread_testcancel)(void);
468 void * (*thread_cancellable_func)(
469 void * (*func)(
void *),
void *func_arg,
void (*cleanup_func)(
void *),
void * cleanup_arg,
globus_bool_t execute_cleanup);
470 int (*thread_pre_activate)(void);
472 globus_thread_impl_t;
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_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
Thread attributes.
Definition: globus_thread.h:88
int globus_bool_t
Boolean type.
Definition: globus_types.h:93
int globus_mutex_destroy(globus_mutex_t *mutex)
Destroy a mutex.
Definition: globus_thread.c:305
Reference Counting Module Activation and Deactivation.
void(* globus_thread_key_destructor_func_t)(void *value)
Thread-specific data destructor.
Definition: globus_thread.h:195
int globus_thread_kill(globus_thread_t thread, int sig)
Send a signal to a thread.
Definition: globus_thread.c:1480
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
int globus_thread_setcancelstate(int state, int *oldstate)
Set the thread's cancellable state.
Definition: globus_thread.c:1781
void * globus_thread_cancellable_func(void *(*func)(void *), void *arg, void(*cleanup_func)(void *), void *cleanup_arg, globus_bool_t execute_cleanup)
Execute a function with thread cleanup in case of cancellation.
Definition: globus_thread.c:1664
Thread once structure.
Definition: globus_thread.h:226
Mutex.
Definition: globus_thread.h:107
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
int globus_condattr_setspace(globus_condattr_t *cond_attr, int space)
Set callback space associated with a condition variable attributeThe globus_condattr_setspace() funct...
Definition: globus_thread.c:894
void globus_thread_yield(void)
Yield execution to another thread.
Definition: globus_thread.c:1362
Condition variable.
Definition: globus_thread.h:124
int globus_thread_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask)
Modify the current thread's signal mask.
Definition: globus_thread.c:1435
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_condattr_getspace(globus_condattr_t *cond_attr, int *space)
Get callback space associated with a condition variable attributeThe globus_condattr_getspace() funct...
Definition: globus_thread.c:937
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_testcancel(void)
Thread cancellation point.
Definition: globus_thread.c:1740
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 func)
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
int globus_thread_equal(globus_thread_t thread1, globus_thread_t thread2)
Check whether thread identifiers match.
Definition: globus_thread.c:1552
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
globus_bool_t globus_thread_preemptive_threads(void)
Indicate whether the active thread model supports preemption.
Definition: globus_thread.c:1583
int globus_thread_set_model(const char *model)
Select threading model for an application.
Definition: globus_thread.c:117
int globus_cond_signal(globus_cond_t *cond)
Signal a condition to a thread.
Definition: globus_thread.c:661
Module Descriptor.
Definition: globus_module.h:71
Mutex attribute.
Definition: globus_thread.h:151