|
rlib
Convenience library for useful things
|
Multi-group, multi-thread task queue with dependencies, cancellation and NUMA-aware worker placement. More...
Go to the source code of this file.
Macros | |
| #define | r_task_ref r_ref_ref |
| Take a reference on a task (alias for r_ref_ref). | |
| #define | r_task_unref r_ref_unref |
| Drop a reference on a task (alias for r_ref_unref). | |
| #define | r_task_queue_ref r_ref_ref |
| Take a reference on the queue (alias for r_ref_ref). | |
| #define | r_task_queue_unref r_ref_unref |
| Drop a reference on the queue (alias for r_ref_unref). | |
| #define | r_task_queue_add_task(queue, task) r_task_queue_add_task_with_group (queue, task, RUINT_MAX) |
| Dispatch a pre-allocated task to any worker group. | |
| #define | r_task_queue_add(queue, func, data, datanotify) r_task_queue_add_full (queue, RUINT_MAX, func, data, datanotify, NULL) |
| Allocate-and-dispatch a task in one call, no dependencies. | |
Typedefs | |
| typedef struct RTask | RTask |
| Opaque, refcounted task handle. | |
| typedef struct RTaskQueue | RTaskQueue |
| Opaque, refcounted task-queue handle. | |
| typedef void(* | RTaskFunc) (rpointer data, RTaskQueue *queue, RTask *task) |
| Task entry-point signature. | |
Functions | |
| rboolean | r_task_add_dep (RTask *task, RTask *dep,...) |
| Add one or more dependencies to a task that has not yet run. | |
| rboolean | r_task_add_dep_v (RTask *task, RTask *dep, va_list args) |
va_list variant of r_task_add_dep. | |
| rboolean | r_task_cancel (RTask *task, rboolean wait_if_running) |
| Cancel a pending or running task. | |
| rboolean | r_task_wait (RTask *task) |
Block until task has finished (cancelled tasks count as finished). | |
| RTaskQueue * | r_task_queue_new (ruint groups, ruint threads_per_group) |
Create a queue with groups worker groups, each containing threads_per_group worker threads. | |
| RTaskQueue * | r_task_queue_new_pin_and_group_on_numa_node (const RBitset *nodeset, ruint threads_per_group) |
One group per NUMA node selected by nodeset, each with threads_per_group workers pinned to that node's CPUs. | |
| RTaskQueue * | r_task_queue_new_pin_on_cpu_group_numa_node (const RBitset *nodeset) |
| One worker per CPU on the selected NUMA nodes, grouped per NUMA node. | |
| RTaskQueue * | r_task_queue_new_pin_on_each_cpu (const RBitset *cpuset, ruint groups) |
One worker per CPU in cpuset; workers are partitioned evenly across groups groups. | |
| RTaskQueue * | r_task_queue_new_pin_on_each_cpu_group_numa_node (const RBitset *cpuset) |
One worker per CPU in cpuset, grouped by the NUMA node each CPU belongs to. | |
| RTaskQueue * | r_task_queue_current (void) |
Return the queue owning the calling thread, or NULL if the calling thread is not a queue worker. | |
| RTask * | r_task_queue_allocate (RTaskQueue *queue, RTaskFunc func, rpointer data, RDestroyNotify datanotify) |
Allocate a task bound to queue without dispatching it. | |
| rboolean | r_task_queue_add_task_with_group (RTaskQueue *queue, RTask *task, ruint group) |
| Dispatch a pre-allocated task to a specific group. | |
| RTask * | r_task_queue_add_full (RTaskQueue *queue, ruint group, RTaskFunc func, rpointer data, RDestroyNotify datanotify,...) R_ATTR_WARN_UNUSED_RESULT |
| Allocate-and-dispatch a task with group and dependencies. | |
| RTask * | r_task_queue_add_full_v (RTaskQueue *queue, ruint group, RTaskFunc func, rpointer data, RDestroyNotify datanotify, va_list args) R_ATTR_WARN_UNUSED_RESULT |
va_list variant of r_task_queue_add_full. | |
| rsize | r_task_queue_queued_tasks (const RTaskQueue *queue) |
| Number of tasks currently queued but not yet running. | |
| ruint | r_task_queue_group_count (const RTaskQueue *queue) |
Number of worker groups in queue. | |
| ruint | r_task_queue_thread_count (const RTaskQueue *queue) |
| Total number of worker threads across all groups. | |
Multi-group, multi-thread task queue with dependencies, cancellation and NUMA-aware worker placement.