14 cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-DDEBUG .
21 Declare the pointer for the pools data, memory is malloc'd when you create the pool:
23 thread_pool_t *pool_id;
25 Create the pool, returns 0 if the pool is created or POOL_CREATE_ERR otherwise. Mode is either CTP_PRIORITY,
26 CTP_FIFO (first in, first out) or FILO (first in, last out):
28 ctp_create_pool(&pool_id, min_threads, max_threads, mode);
30 Add a job to the pool, priority is 1 first, 99 last (ignored if mode is CTP_PRIORITY), *data must be a
31 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:
33 ctp_add_job(pool_id, priority, *function, *data);
35 Kill the pool, destorys all jobs & threads, after already running jobs finish, returns 0 when the pool is killed:
37 ctp_kill_pool(&pool_id);
39 Pause/start the pool, already running jobs continue, no new jobs are started:
41 ctp_pause_pool(pool_id);
42 ctp_start_pool(pool_id);
44 Change max/min threads:
46 ctp_max_threads(pool_id, max_threads);
47 ctp_min_threads(pool_id, min_threads);
49 POOL_DEAD is returned by ctp_add_job, ctp_kill_pool, ctp_pause_pool, ctp_start_pool, ctp_max_threads &
50 ctp_min_threads if a null pointer is passed to them
52 example.c contains sample code