|
Veritable Lasagna
An Allocator & Data Structure Library for C.
|
Include dependency graph for vl_thread_pool.c:Functions | |
| VL_API vl_thread_pool * | vlThreadPoolNew (vl_uint_t worker_count) |
| Creates a new priority-aware thread pool with work-stealing. | |
| VL_API void | vlThreadPoolDelete (vl_thread_pool *pool) |
| Deletes a thread pool and frees all associated resources. | |
| VL_API vl_bool_t | vlThreadPoolEnqueuePriority (vl_thread_pool *pool, vl_thread_pool_priority priority, const vl_thread_pool_task *task) |
| Enqueues a single work item at the specified priority level. | |
| VL_API vl_uint_t | vlThreadPoolEnqueueBatchPriority (vl_thread_pool *pool, vl_thread_pool_priority priority, const vl_thread_pool_task *tasks, vl_uint_t count) |
| Enqueues multiple work items at the same priority level in a batch. | |
| VL_API vl_bool_t | vlThreadPoolWait (vl_thread_pool *pool, vl_uint_t timeout_ms) |
| Waits until all enqueued tasks across all priority tiers have completed. | |
| VL_API void | vlThreadPoolShutdown (vl_thread_pool *pool) |
| Initiates graceful shutdown of the thread pool. | |
| VL_API void | vlThreadPoolGetStats (vl_thread_pool *pool, vl_thread_pool_stats *out_stats) |
| Retrieves a snapshot of current thread pool statistics. | |
| VL_API void vlThreadPoolDelete | ( | vl_thread_pool * | pool | ) |
Deletes a thread pool and frees all associated resources.
Threads must have been joined via shutdown. If threads are still active, behavior is undefined.
NULL (no-op).| pool | Thread pool handle to delete |
Here is the call graph for this function:| VL_API vl_uint_t vlThreadPoolEnqueueBatchPriority | ( | vl_thread_pool * | pool, |
| vl_thread_pool_priority | priority, | ||
| const vl_thread_pool_task * | tasks, | ||
| vl_uint_t | count | ||
| ) |
Enqueues multiple work items at the same priority level in a batch.
This is more efficient than multiple individual enqueues. All tasks are added to the same priority queue atomically.
tasks array into its internal storage.pool or tasks is NULL.| pool | Thread pool handle |
| priority | Priority level for all tasks |
| tasks | Pointer to array of task structures |
| count | Number of tasks in the array |
Here is the call graph for this function:| VL_API vl_bool_t vlThreadPoolEnqueuePriority | ( | vl_thread_pool * | pool, |
| vl_thread_pool_priority | priority, | ||
| const vl_thread_pool_task * | task | ||
| ) |
Enqueues a single work item at the specified priority level.
The task is atomically added to the appropriate priority queue and a waiting worker thread is signaled. If no workers are waiting, the task is queued for later execution.
task data into its internal storage. The caller retains ownership of the task pointer.VL_FALSE if pool or task is NULL.VL_FALSE if the pool is in the process of shutting down.VL_TRUE if the task was successfully enqueued, VL_FALSE otherwise.| pool | Thread pool handle |
| priority | Priority level (HIGH, MEDIUM, or LOW) |
| task | Pointer to task structure (copied internally) |
Here is the call graph for this function:| VL_API void vlThreadPoolGetStats | ( | vl_thread_pool * | pool, |
| vl_thread_pool_stats * | out_stats | ||
| ) |
Retrieves a snapshot of current thread pool statistics.
Returns completed task count and per-priority queue depths.
pool and out_stats should not be NULL.NULL.| pool | Thread pool handle |
| out_stats | Pointer to stats structure to populate |
| VL_API vl_thread_pool * vlThreadPoolNew | ( | vl_uint_t | worker_count | ) |
Creates a new priority-aware thread pool with work-stealing.
Worker threads are created immediately and begin waiting for work. Threads employ a work-stealing strategy: HIGH -> MEDIUM -> LOW, with stealing from lower tiers when higher tiers are empty.
vl_thread_pool handle and is responsible for calling vlThreadPoolDelete.vlThreadPoolDelete.NULL if worker_count is 0 or if the pool could not be created.NULL if any heap allocation fails or if worker threads cannot be spawned.NULL on failure.| worker_count | Number of worker threads to create (must be > 0) |
Here is the call graph for this function:| VL_API void vlThreadPoolShutdown | ( | vl_thread_pool * | pool | ) |
Initiates graceful shutdown of the thread pool.
After calling this function:
This function does not wait for threads. Use vlThreadPoolWait() to block until idle, or vlThreadPoolDelete() to join and cleanup.
NULL (no-op).| pool | Thread pool handle |
Here is the call graph for this function:
Here is the caller graph for this function:| VL_API vl_bool_t vlThreadPoolWait | ( | vl_thread_pool * | pool, |
| vl_uint_t | timeout_ms | ||
| ) |
Waits until all enqueued tasks across all priority tiers have completed.
Blocks the calling thread until all HIGH, MEDIUM, and LOW priority queues are empty and all workers are idle. May be called concurrently from multiple threads; all will unblock when the pool becomes empty.
VL_FALSE if pool is NULL.VL_FALSE if the timeout expires.VL_TRUE if the pool became idle within the timeout, VL_FALSE otherwise.| pool | Thread pool handle |
| timeout_ms | Maximum time to wait in milliseconds (0 = infinite) |
Here is the call graph for this function: