Asynchronous Thread Pool Management Functions. More...
Go to the source code of this file.
Data Structures | |
struct | qsc_threadpool_state |
The thread pool state. More... | |
Macros | |
#define | QSC_THREADPOOL_THREADS_MAX 1024ULL |
The thread pool maximum threads. | |
Functions | |
QSC_EXPORT_API bool | qsc_threadpool_add_task (qsc_threadpool_state *ctx, void(*func)(void *), void *state) |
Add a task to the thread-pool. | |
QSC_EXPORT_API void | qsc_threadpool_clear (qsc_threadpool_state *ctx) |
Clear all tasks from the thread-pool. | |
QSC_EXPORT_API void | qsc_threadpool_initialize (qsc_threadpool_state *ctx) |
Initialize the thread-pool. | |
QSC_EXPORT_API void | qsc_threadpool_sort (qsc_threadpool_state *ctx) |
Sort the threads in the pool, placing active threads at the start of the array. | |
QSC_EXPORT_API bool | qsc_threadpool_thread_active (const qsc_threadpool_state *ctx, size_t index) |
Check if a thread is active. | |
QSC_EXPORT_API void | qsc_threadpool_remove_task (qsc_threadpool_state *ctx, size_t index) |
Remove a task from the thread-pool. | |
Asynchronous Thread Pool Management Functions.
This header defines the public API for managing an asynchronous thread pool. The thread pool enables the scheduling and execution of tasks concurrently by spawning multiple threads. It provides functions to add tasks to the pool, clear all tasks, initialize the pool, sort the threads to prioritize active tasks, check thread activity, and remove individual tasks.
QSC_EXPORT_API bool qsc_threadpool_add_task | ( | qsc_threadpool_state * | ctx, |
void(* | func )(void *), | ||
void * | state ) |
Add a task to the thread-pool.
ctx | [qsc_threadpool_state*] The thread pool state |
func | [(func)(void)] A pointer to the thread function |
state | [void*] The thread state |
QSC_EXPORT_API void qsc_threadpool_clear | ( | qsc_threadpool_state * | ctx | ) |
Clear all tasks from the thread-pool.
ctx | [qsc_threadpool_state*] The thread pool state |
QSC_EXPORT_API void qsc_threadpool_initialize | ( | qsc_threadpool_state * | ctx | ) |
Initialize the thread-pool.
ctx | [qsc_threadpool_state*] The thread pool state |
QSC_EXPORT_API void qsc_threadpool_remove_task | ( | qsc_threadpool_state * | ctx, |
size_t | index ) |
Remove a task from the thread-pool.
ctx | [qsc_threadpool_state*] The thread pool state |
index | [size_t] The thread index |
QSC_EXPORT_API void qsc_threadpool_sort | ( | qsc_threadpool_state * | ctx | ) |
Sort the threads in the pool, placing active threads at the start of the array.
ctx | [qsc_threadpool_state*] The thread pool state |
QSC_EXPORT_API bool qsc_threadpool_thread_active | ( | const qsc_threadpool_state * | ctx, |
size_t | index ) |
Check if a thread is active.
ctx | [const qsc_threadpool_state*] The thread pool state |
index | [size_t] The thread index |