#include <citrusleaf/cf_queue.h>
#include <pthread.h>
Go to the source code of this file.
typedef void(* as_fini_fn)() |
typedef void(* as_task_fn)(void *user_data) |
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
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