THREAD_POOL
Module: THREADS: tools to create and manage a thread pool
Structure of a thread pool.
#include "n_thread_pool.h"
Public Attributes
| Name | |
|---|---|
| LIST * | waiting_list Waiting list handling. |
| THREAD_POOL_NODE ** | thread_list Dynamically allocated but fixed size thread array. |
| sem_t | nb_tasks semaphore signaling pool idle state: value 0 = work in progress, value 1 = pool is idle (no active threads, empty waiting list). |
| size_t | nb_max_waiting Maximum number of waiting procedures in the list, 0 for unlimited. |
| size_t | nb_actives number of threads actually doing a proc |
| size_t | max_threads Maximum number of running threads in the list. |
| pthread_mutex_t | lock mutex to prevent mutual access of waiting_list parameters |
| void(*)(void *param) | discard Called by destroy_threaded_pool() with the param of every queued job it discards without running, so the caller can release it. |
Public Attributes Documentation
variable waiting_list
LIST * waiting_list;
Waiting list handling.
variable thread_list
THREAD_POOL_NODE ** thread_list;
Dynamically allocated but fixed size thread array.
variable nb_tasks
sem_t nb_tasks;
semaphore signaling pool idle state: value 0 = work in progress, value 1 = pool is idle (no active threads, empty waiting list).
Consumed by add_threaded_process and posted back only by refresh_thread_pool, so wait_for_threaded_pool() polls refresh rather than blocking on it.
variable nb_max_waiting
size_t nb_max_waiting;
Maximum number of waiting procedures in the list, 0 for unlimited.
variable nb_actives
size_t nb_actives;
number of threads actually doing a proc
variable max_threads
size_t max_threads;
Maximum number of running threads in the list.
variable lock
pthread_mutex_t lock;
mutex to prevent mutual access of waiting_list parameters
variable discard
void(*)(void *param) discard;
Called by destroy_threaded_pool() with the param of every queued job it discards without running, so the caller can release it.
NULL by default: the params are then left alone and only counted in the log. Set with set_thread_pool_discard().
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB