ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
thread_pool.h
Go to the documentation of this file.
1#pragma once
2
73#include <stdint.h>
74#include <stdbool.h>
75#include "common.h"
77
78// Forward declaration
81
90 int stop_id;
91 void *(*thread_func)(void *);
92 void *thread_arg;
93 char name[64];
95};
96
109
119thread_pool_t *thread_pool_create(const char *pool_name);
120
131
159asciichat_error_t thread_pool_spawn(thread_pool_t *pool, void *(*thread_func)(void *), void *thread_arg, int stop_id,
160 const char *thread_name);
161
181
190size_t thread_pool_get_count(const thread_pool_t *pool);
191
200bool thread_pool_has_threads(const thread_pool_t *pool);
🔌 Cross-platform abstraction layer umbrella header for ascii-chat
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:46
pthread_mutex_t mutex_t
Mutex type (POSIX: pthread_mutex_t)
Definition mutex.h:38
pthread_t asciichat_thread_t
Thread handle type (POSIX: pthread_t)
Thread pool entry (internal linked list node)
Definition thread_pool.h:88
void * thread_arg
Thread argument.
Definition thread_pool.h:92
asciichat_thread_t thread
Thread handle.
Definition thread_pool.h:89
struct thread_pool_entry * next
Linked list next pointer.
Definition thread_pool.h:94
int stop_id
Cleanup order (lower = stop first, -1 = unordered)
Definition thread_pool.h:90
char name[64]
Thread name for debugging.
Definition thread_pool.h:93
Thread pool structure.
mutex_t threads_mutex
Mutex protecting thread list.
thread_pool_entry_t * threads
Linked list of threads (sorted by stop_id)
size_t thread_count
Number of threads in pool.
char name[64]
Pool name for debugging.
void thread_pool_destroy(thread_pool_t *pool)
Destroy a thread pool.
Definition thread_pool.c:43
thread_pool_t * thread_pool_create(const char *pool_name)
Create a new thread pool.
Definition thread_pool.c:12
size_t thread_pool_get_count(const thread_pool_t *pool)
Get thread count in the pool.
bool thread_pool_has_threads(const thread_pool_t *pool)
Check if pool has any threads.
asciichat_error_t thread_pool_spawn(thread_pool_t *pool, void *(*thread_func)(void *), void *thread_arg, int stop_id, const char *thread_name)
Spawn a worker thread in the pool.
Definition thread_pool.c:65
asciichat_error_t thread_pool_stop_all(thread_pool_t *pool)
Stop all threads in the pool in stop_id order.
Common SIMD utilities and structures.