ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
thread_pool Struct Reference

Thread pool structure. More...

#include <include/ascii-chat/thread_pool.h>

Data Fields

char name [64]
 Pool name for debugging.
thread_pool_entry_t * threads
 Linked list of threads (sorted by stop_id).
mutex_t threads_mutex
 Mutex protecting thread list.
size_t thread_count
 Number of threads in pool.
bool is_work_queue_mode
 True if using work queue mode.
size_t num_workers
 Number of pre-created worker threads.
thread_pool_work_entry_t * work_queue
 Queue of pending work.
mutex_t work_queue_mutex
 Mutex protecting work queue.
cond_t work_available
 Condition variable for workers to wait on.
bool shutdown_requested
 Signal workers to exit.

Detailed Description

Thread pool structure.

Manages a collection of worker threads with ordered cleanup support. Thread-safe for concurrent spawn/stop operations.

Can operate in two modes:

  1. Long-lived threads mode (original): spawn() creates permanent threads
  2. Work queue mode (new): pre-created workers pull tasks from a queue

Definition at line 131 of file thread_pool.h.

Field Documentation

◆ is_work_queue_mode

bool thread_pool::is_work_queue_mode

◆ name

◆ num_workers

size_t thread_pool::num_workers

Number of pre-created worker threads.

Definition at line 139 of file thread_pool.h.

Referenced by thread_pool_create(), thread_pool_create_with_workers(), and thread_pool_queue_work().

◆ shutdown_requested

bool thread_pool::shutdown_requested

Signal workers to exit.

Definition at line 143 of file thread_pool.h.

Referenced by thread_pool_create_with_workers(), and thread_pool_stop_all().

◆ thread_count

size_t thread_pool::thread_count

◆ threads

thread_pool_entry_t* thread_pool::threads

◆ threads_mutex

mutex_t thread_pool::threads_mutex

◆ work_available

cond_t thread_pool::work_available

Condition variable for workers to wait on.

Definition at line 142 of file thread_pool.h.

Referenced by thread_pool_create_with_workers(), thread_pool_destroy(), thread_pool_queue_work(), and thread_pool_stop_all().

◆ work_queue

thread_pool_work_entry_t* thread_pool::work_queue

Queue of pending work.

Definition at line 140 of file thread_pool.h.

Referenced by thread_pool_create_with_workers(), thread_pool_destroy(), and thread_pool_queue_work().

◆ work_queue_mutex

mutex_t thread_pool::work_queue_mutex

Mutex protecting work queue.

Definition at line 141 of file thread_pool.h.

Referenced by thread_pool_create_with_workers(), thread_pool_destroy(), thread_pool_queue_work(), and thread_pool_stop_all().


The documentation for this struct was generated from the following file: