![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Thread pool declaration. More...
Include dependency graph for n_thread_pool.h:
This graph shows which files directly or indirectly include this file: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 4 |
| processing mode for added func, direct start, not queued | |
| #define | EXITED_THREAD 512 |
| indicate that the pool is off, all jobs have been consumed | |
| #define | EXITING_THREAD 256 |
| 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 16 |
| status of a thread which is waiting for some proc | |
| #define | NO_LOCK 1024 |
| if passed to add_threaded_process, skip main table lock in case we are in a func which is already locking it | |
| #define | NO_QUEUE 8 |
| special processing mode for waiting_list: do not add the work in queue since it' coming from the queue | |
| #define | NORMAL_PROC 1 |
| processing mode for added func, synced start, can be queued | |
| #define | RUNNING_PROC 64 |
| status of a thread which proc is currently running | |
| #define | RUNNING_THREAD 128 |
| indicate that the pool is running and ready to use | |
| #define | SYNCED_PROC 2 |
| processing mode for added func, synced start, not queued | |
| #define | WAITING_PROC 32 |
| 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, unsigned int delay) |
| delete a thread_pool, exit the threads and free the structs | |
| long int | get_nb_cpu_cores () |
| get number of core of current system | |
| THREAD_POOL * | new_thread_pool (size_t nbmaxthr, size_t 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 execution 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, unsigned int delay) |
| Wait for all the launched process in the thread pool to terminate. | |