cp_thread_pool *cp_thread_pool_create(int min_size, int max_size);
void cp_thread_pool_destroy(cp_thread_pool *pool);
int cp_thread_pool_stop(cp_thread_pool *pool);
cp_thread *cp_thread_pool_get(cp_thread_pool *pool,
cp_thread_action action, void *prm);
cp_thread *cp_thread_pool_get_stoppable(cp_thread_pool *pool,
cp_thread_action action,
void *action_prm,
cp_thread_stop_fn stop_fn,
void *stop_prm);
cp_thread *cp_thread_pool_get_nb(cp_thread_pool *pool,
cp_thread_action action, void *prm);
cp_thread *cp_thread_pool_get_stoppable_nb(cp_thread_pool *pool,
cp_thread_action action,
void *action_prm,
cp_thread_stop_fn stop_fn,
void *stop_prm);
cp_thread *cp_thread_pool_get_impl(cp_thread_pool *pool,
cp_thread_action action,
void *action_prm,
cp_thread_stop_fn stop_fn,
void *stop_prm,
int block);
int cp_thread_pool_wait(cp_thread_pool *pool);
int cp_thread_pool_count_available(cp_thread_pool *pool);
cp_thread_pool_get_nb never blocks but may return NULL if the pool has reached maximal size and no free threads are available.
cp_thread_pool_get_stoppable allows specifying a stop function and an optional stop parameter. The stop function is called by the framework on shutdown - enabling client code to terminate and perform cleanup for example. If no stop parameter is set, the stop function is invoked with the action parameter the client thread was initialized with. cp_thread_pool_get_stoppable_nb is the equivalent non-blocking version.
The stop function should be defined as
int cp_thread_stop_function(void *stop_prm);
Load balancing different operations by switching threads from one to the other can be done by defining a cp_pooled_thread_client_interface(3) for each action and registering them with the same cp_pooled_thread_scheduler(3).
cp_thread_pool_wait blocks until all threads are done executing.
This document was created by
man2html,
using the manual pages. Time: 23:42:32 GMT, May 09, 2006 |