Mercury
mercury_thread.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Argonne National Laboratory, Department of Energy,
3  *                    UChicago Argonne, LLC and The HDF Group.
4  * All rights reserved.
5  *
6  * The full copyright notice, including terms governing use, modification,
7  * and redistribution, is contained in the COPYING file that can be
8  * found at the root of the source code distribution tree.
9  */
10 
11 #ifndef MERCURY_THREAD_H
12 #define MERCURY_THREAD_H
13 
14 #include "mercury_util_config.h"
15 
16 #ifdef _WIN32
17  #include <windows.h>
18  typedef HANDLE hg_thread_t;
19  typedef LPTHREAD_START_ROUTINE hg_thread_func_t;
20  typedef DWORD hg_thread_ret_t;
21  #define HG_THREAD_RETURN_TYPE hg_thread_ret_t WINAPI
22  typedef DWORD hg_thread_key_t;
23 #else
24  #include <pthread.h>
25  typedef pthread_t hg_thread_t;
26  typedef void *(*hg_thread_func_t)(void *);
27  typedef void *hg_thread_ret_t;
28  #define HG_THREAD_RETURN_TYPE hg_thread_ret_t
29  typedef pthread_key_t hg_thread_key_t;
30 #endif
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
41 HG_UTIL_EXPORT void
43 
53 HG_UTIL_EXPORT int
54 hg_thread_create(hg_thread_t *thread, hg_thread_func_t f, void *data);
55 
63 HG_UTIL_EXPORT void
65 
73 HG_UTIL_EXPORT int
75 
83 HG_UTIL_EXPORT int
85 
93 HG_UTIL_EXPORT int
95 
104 HG_UTIL_EXPORT int
106 
114 HG_UTIL_EXPORT void *
116 
125 HG_UTIL_EXPORT int
126 hg_thread_setspecific(hg_thread_key_t key, const void *value);
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif /* MERCURY_THREAD_H */
HG_UTIL_EXPORT int hg_thread_key_delete(hg_thread_key_t key)
Delete a thread-specific data key previously returned by hg_thread_key_create().
pthread_t hg_thread_t
HG_UTIL_EXPORT int hg_thread_cancel(hg_thread_t thread)
Terminate the thread.
HG_UTIL_EXPORT void hg_thread_exit(hg_thread_ret_t ret)
Ends the calling thread.
HG_UTIL_EXPORT void hg_thread_init(hg_thread_t *thread)
Initialize the thread.
HG_UTIL_EXPORT int hg_thread_join(hg_thread_t thread)
Wait for thread completion.
pthread_key_t hg_thread_key_t
HG_UTIL_EXPORT int hg_thread_create(hg_thread_t *thread, hg_thread_func_t f, void *data)
Create a new thread for the given function.
void * hg_thread_ret_t
HG_UTIL_EXPORT void * hg_thread_getspecific(hg_thread_key_t key)
Get value from specified key.
HG_UTIL_EXPORT int hg_thread_key_create(hg_thread_key_t *key)
Create a thread-specific data key visible to all threads in the process.
void *(* hg_thread_func_t)(void *)
HG_UTIL_EXPORT int hg_thread_setspecific(hg_thread_key_t key, const void *value)
Set value to specified key.