![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Thread pool declaration. More...
Go to the source code of this file.
Data Structures | |
struct | THREAD_POOL |
Structure of a trhead pool. More... | |
struct | THREAD_POOL_NODE |
A thread pool node. More... | |
struct | THREAD_WAITING_PROC |
Structure of a waiting process item. More... | |
Macros | |
#define | DIRECT_PROC 2 |
processing mode for added func, direct start | |
#define | EXITED_THREAD 256 |
indicate that the pool is off, all jobs have been consumed | |
#define | EXITING_THREAD 128 |
indicate that the pool is exiting, unfinished jobs will finish and the pool will exit the threads and enter the EXITED state | |
#define | IDLE_PROC 8 |
status of a thread which is waiting for some proc | |
#define | NO_LOCK 512 |
if passed to add_threaded_process, skip main table lock in case we are in a func which is already locking it | |
#define | NOQUEUE 4 |
processing mode for waiting_list: do not readd the work in queue | |
#define | RUNNING_PROC 32 |
status of a thread which proc is currently running | |
#define | RUNNING_THREAD 64 |
indicate that the pool is running and ready to use | |
#define | SYNCED_PROC 1 |
processing mode for added func, synced start | |
#define | WAITING_PROC 16 |
status of a thread who have proc waiting to be processed | |
Functions | |
int | add_threaded_process (THREAD_POOL *thread_pool, void *(*func_ptr)(void *param), void *param, int mode) |
add a function and params to a thread pool | |
int | destroy_threaded_pool (THREAD_POOL **thread_pool, int delay) |
delete a thread_pool, exit the threads and free the structs | |
int | get_nb_cpu_cores () |
get number of core of current system | |
THREAD_POOL * | new_thread_pool (int nbmaxthr, int nb_max_waiting) |
Create a new pool of nbmaxthr threads. | |
int | refresh_thread_pool (THREAD_POOL *thread_pool) |
try to add some waiting DIRECT_PROCs on some free thread slots, else do nothing | |
int | start_threaded_pool (THREAD_POOL *thread_pool) |
Launch the process waiting for exectution in the thread pool. | |
int | wait_for_synced_threaded_pool (THREAD_POOL *thread_pool) |
wait for all the launched process, blocking but light on the CPU as there is no polling | |
int | wait_for_threaded_pool (THREAD_POOL *thread_pool, int delay) |
Wait for all the launched process in the thread pool to terminate. | |