Mercury
Typedefs | Functions
mercury_thread_pool.h File Reference
#include "mercury_util_config.h"
#include "mercury_thread.h"
Include dependency graph for mercury_thread_pool.h:

Go to the source code of this file.

Typedefs

typedef struct hg_thread_pool hg_thread_pool_t
 

Functions

HG_UTIL_EXPORT int hg_thread_pool_init (unsigned int thread_count, hg_thread_pool_t **pool)
 Initialize the thread pool. More...
 
HG_UTIL_EXPORT int hg_thread_pool_destroy (hg_thread_pool_t *pool)
 Destroy the thread pool. More...
 
HG_UTIL_EXPORT int hg_thread_pool_post (hg_thread_pool_t *pool, hg_thread_func_t f, void *args)
 Post the work function f to the pool. More...
 

Typedef Documentation

typedef struct hg_thread_pool hg_thread_pool_t

Definition at line 17 of file mercury_thread_pool.h.

Function Documentation

HG_UTIL_EXPORT int hg_thread_pool_init ( unsigned int  thread_count,
hg_thread_pool_t **  pool 
)

Initialize the thread pool.

Parameters
thread_count[IN] number of threads that will be created at initialization
pool[OUT] pointer to pool object
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_thread_pool_destroy ( hg_thread_pool_t pool)

Destroy the thread pool.

Parameters
pool[IN/OUT] pointer to pool object
Returns
Non-negative on success or negative on failure
HG_UTIL_EXPORT int hg_thread_pool_post ( hg_thread_pool_t pool,
hg_thread_func_t  f,
void *  args 
)

Post the work function f to the pool.

Note that the operation may be queued depending on the number of threads and number of tasks already running.

Parameters
pool[IN/OUT] pointer to pool object
f[IN] pointer to function
args[IN] pointer to data that can be passed to function f
Returns
Non-negative on success or negative on failure