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 } 307 globus_abstime_t * abstime);
346 globus_thread_func_t func,
375 void (*init_routine)(
void));
385 const sigset_t * newmask,
419 void * (*func)(
void *),
421 void (*cleanup_func)(
void *),
444 #define GLOBUS_THREAD_CANCEL_DISABLE 0 450 #define GLOBUS_THREAD_CANCEL_ENABLE 1 455 globus_i_thread_pre_activate();
465 #define GLOBUS_THREAD_MODULE (&globus_i_thread_module) 492 void (*thread_yield)(void);
493 void (*thread_exit)(
void *value);
494 int (*thread_sigmask)(
int how,
const sigset_t *newmask, sigset_t *oldmask);
496 int (*thread_setcancelstate)(
int state,
int *oldstate);
497 void (*thread_testcancel)(void);
503 void * (*thread_cancellable_func)(
504 void * (*func)(
void *),
void *func_arg,
void (*cleanup_func)(
void *),
void * cleanup_arg,
globus_bool_t execute_cleanup);
505 int (*thread_pre_activate)(void);
507 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:634
globus_bool_t globus_i_am_only_thread(void)
Determine if threads are supported.
Definition: globus_thread.c:1619
int globus_cond_broadcast(globus_cond_t *cond)
Signal a condition to multiple threads.
Definition: globus_thread.c:709
int globus_cond_wait(globus_cond_t *cond, globus_mutex_t *mutex)
Wait for a condition to be signalled.
Definition: globus_thread.c:581
int globus_thread_key_delete(globus_thread_key_t key)
Delete a thread-local storage key.
Definition: globus_thread.c:1134
int globus_cond_destroy(globus_cond_t *cond)
Destroy a condition variable.
Definition: globus_thread.c:535
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:309
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:1481
int globus_mutex_init(globus_mutex_t *mutex, globus_mutexattr_t *attr)
Initialize a mutex.
Definition: globus_thread.c:270
void * globus_thread_getspecific(globus_thread_key_t key)
Get a thread-specific data value.
Definition: globus_thread.c:1271
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:495
int globus_thread_setspecific(globus_thread_key_t key, void *value)
Set a thread-specific data value.
Definition: globus_thread.c:1328
int globus_thread_setcancelstate(int state, int *oldstate)
Set the thread's cancellable state.
Definition: globus_thread.c:1790
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:1670
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:1515
int globus_mutex_unlock(globus_mutex_t *mutex)
Unlock a mutex.
Definition: globus_thread.c:394
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:908
void globus_thread_yield(void)
Yield execution to another thread.
Definition: globus_thread.c:1360
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:866
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:828
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:951
int globus_thread_once(globus_thread_once_t *once, void(*init_routine)(void))
Execute a function one time.
Definition: globus_thread.c:1213
Thread-specific data key.
Definition: globus_thread.h:201
void globus_thread_testcancel(void)
Thread cancellation point.
Definition: globus_thread.c:1748
void globus_thread_exit(void *value)
Terminate the current thread.
Definition: globus_thread.c:1385
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:1091
int globus_thread_cancel(globus_thread_t thr)
Cancel a thread.
Definition: globus_thread.c:1716
int globus_mutex_lock(globus_mutex_t *mutex)
Lock a mutex.
Definition: globus_thread.c:352
int globus_thread_equal(globus_thread_t thread1, globus_thread_t thread2)
Check whether thread identifiers match.
Definition: globus_thread.c:1555
int globus_mutex_trylock(globus_mutex_t *mutex)
Lock a mutex if it is not locked.
Definition: globus_thread.c:438
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:1013
globus_bool_t globus_thread_preemptive_threads(void)
Indicate whether the active thread model supports preemption.
Definition: globus_thread.c:1587
int globus_thread_set_model(const char *model)
Select threading model for an application.
Definition: globus_thread.c:118
int globus_cond_signal(globus_cond_t *cond)
Signal a condition to a thread.
Definition: globus_thread.c:672
Module Descriptor.
Definition: globus_module.h:71
Mutex attribute.
Definition: globus_thread.h:151