Build
========
Release mode:
cmake .
make
make install
Debug mode:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-DDEBUG .
make
make install
api
======
Declare the pointer for the pools data, memory is malloc'd when you create the pool:
thread_pool_t *pool_id;
Create the pool, returns 0 if the pool is created or POOL_CREATE_ERR otherwise. Mode is either CTP_PRIORITY,
CTP_FIFO (first in, first out) or FILO (first in, last out):
ctp_create_pool(&pool_id, min_threads, max_threads, mode);
Add a job to the pool, priority is 1 first, 99 last (ignored if mode is CTP_PRIORITY), *data must be a
pointer to already malloc'd memory, returns 0 if the job is added, JOB_CREATE_ERR otherwise. *data must be free'd before the function end:
ctp_add_job(pool_id, priority, *function, *data);
Kill the pool, destorys all jobs & threads, after already running jobs finish, returns 0 when the pool is killed:
ctp_kill_pool(&pool_id);
Pause/start the pool, already running jobs continue, no new jobs are started:
ctp_pause_pool(pool_id);
ctp_start_pool(pool_id);
Change max/min threads:
ctp_max_threads(pool_id, max_threads);
ctp_min_threads(pool_id, min_threads);
POOL_DEAD is returned by ctp_add_job, ctp_kill_pool, ctp_pause_pool, ctp_start_pool, ctp_max_threads &
ctp_min_threads if a null pointer is passed to them
example.c contains sample code