Mercury
Macros | Typedefs | Functions
mercury_thread.h File Reference
#include "mercury_util_config.h"
#include <pthread.h>
Include dependency graph for mercury_thread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HG_THREAD_RETURN_TYPE   hg_thread_ret_t
 

Typedefs

typedef pthread_t hg_thread_t
 
typedef void *(* hg_thread_func_t )(void *)
 
typedef void * hg_thread_ret_t
 
typedef pthread_key_t hg_thread_key_t
 

Functions

HG_UTIL_EXPORT void hg_thread_init (hg_thread_t *thread)
 Initialize the thread. More...
 
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. More...
 
HG_UTIL_EXPORT void hg_thread_exit (hg_thread_ret_t ret)
 Ends the calling thread. More...
 
HG_UTIL_EXPORT int hg_thread_join (hg_thread_t thread)
 Wait for thread completion. More...
 
HG_UTIL_EXPORT int hg_thread_cancel (hg_thread_t thread)
 Terminate the thread. More...
 
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. More...
 
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(). More...
 
HG_UTIL_EXPORT void * hg_thread_getspecific (hg_thread_key_t key)
 Get value from specified key. More...
 
HG_UTIL_EXPORT int hg_thread_setspecific (hg_thread_key_t key, const void *value)
 Set value to specified key. More...
 

Macro Definition Documentation

#define HG_THREAD_RETURN_TYPE   hg_thread_ret_t

Definition at line 28 of file mercury_thread.h.

Typedef Documentation

typedef pthread_t hg_thread_t

Definition at line 25 of file mercury_thread.h.

typedef void*(* hg_thread_func_t)(void *)

Definition at line 26 of file mercury_thread.h.

typedef void* hg_thread_ret_t

Definition at line 27 of file mercury_thread.h.

typedef pthread_key_t hg_thread_key_t

Definition at line 29 of file mercury_thread.h.

Function Documentation

HG_UTIL_EXPORT void hg_thread_init ( hg_thread_t thread)

Initialize the thread.

Parameters
thread[IN/OUT] pointer to thread object
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.

Parameters
thread[IN/OUT] pointer to thread object
f[IN] pointer to function
data[IN] pointer to data than be passed to function f
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT void hg_thread_exit ( hg_thread_ret_t  ret)

Ends the calling thread.

Parameters
ret[IN] exit code for the thread
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_thread_join ( hg_thread_t  thread)

Wait for thread completion.

Parameters
thread[IN] thread object
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_thread_cancel ( hg_thread_t  thread)

Terminate the thread.

Parameters
thread[IN] thread object
Returns
Non-negative on success or negative on failure
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.

Parameters
key[OUT] pointer to thread key object
Returns
Non-negative on success or negative on failure
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().

Parameters
key[IN] thread key object
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT void* hg_thread_getspecific ( hg_thread_key_t  key)

Get value from specified key.

Parameters
key[IN] thread key object
Returns
Pointer to data associated to the key
HG_UTIL_EXPORT int hg_thread_setspecific ( hg_thread_key_t  key,
const void *  value 
)

Set value to specified key.

Parameters
key[IN] thread key object
value[IN] pointer to data that will be associated
Returns
Non-negative on success or negative on failure