All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Typedefs | Functions
as_thread_pool.h File Reference
#include <citrusleaf/cf_queue.h>
#include <pthread.h>
+ Include dependency graph for as_thread_pool.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  as_thread_pool
 

Typedefs

typedef void(* as_fini_fn )()
 
typedef void(* as_task_fn )(void *user_data)
 

Functions

int as_thread_pool_destroy (as_thread_pool *pool)
 
int as_thread_pool_init (as_thread_pool *pool, uint32_t thread_size)
 
int as_thread_pool_init_fixed (as_thread_pool *pool, uint32_t thread_size, as_task_fn task_fn, uint32_t task_size, uint32_t task_complete_offset)
 
int as_thread_pool_queue_task (as_thread_pool *pool, as_task_fn task_fn, void *task)
 
int as_thread_pool_queue_task_fixed (as_thread_pool *pool, void *task)
 
int as_thread_pool_resize (as_thread_pool *pool, uint32_t thread_size)
 

Typedef Documentation

typedef void(* as_fini_fn)()

Thread finalization function callback.

Definition at line 40 of file as_thread_pool.h.

typedef void(* as_task_fn)(void *user_data)

Task function callback.

Definition at line 34 of file as_thread_pool.h.

Function Documentation

int as_thread_pool_destroy ( as_thread_pool pool)
private

Destroy thread pool.

Returns: 0 : Success -1 : Failed to lock mutex -2 : Pool has already been closed

int as_thread_pool_init ( as_thread_pool pool,
uint32_t  thread_size 
)
private

Initialize variable task thread pool and start thread_size threads. Multiple task types can be handled in variable task thread pools.

Returns: 0 : Success -1 : Failed to initialize mutex lock -2 : Failed to lock mutex -3 : Some threads failed to start

int as_thread_pool_init_fixed ( as_thread_pool pool,
uint32_t  thread_size,
as_task_fn  task_fn,
uint32_t  task_size,
uint32_t  task_complete_offset 
)
private

Initialize fixed task thread pool and start thread_size threads. Only one task type structure can be handled in fixed task thread pools. Fixed task thread pools do save an extra malloc when queuing the task, because a shallow copy is made when pushing the task onto the queue.

Returns: 0 : Success -1 : Failed to initialize mutex lock -2 : Failed to lock mutex -3 : Some threads failed to start

int as_thread_pool_queue_task ( as_thread_pool pool,
as_task_fn  task_fn,
void *  task 
)
private

Queue a variable task onto thread pool.

Returns: 0 : Success -1 : No threads are running to process task. -2 : Failed to push task onto dispatch queue

int as_thread_pool_queue_task_fixed ( as_thread_pool pool,
void *  task 
)
private

Queue a fixed task onto thread pool.

Returns: 0 : Success -1 : No threads are running to process task. -2 : Failed to push task onto dispatch queue

int as_thread_pool_resize ( as_thread_pool pool,
uint32_t  thread_size 
)
private

Resize number of running threads in thread pool.

Returns: 0 : Success -1 : Failed to lock mutex -2 : Pool has already been closed -3 : Some threads failed to start