18#ifndef __R_TASK_QUEUE_H__
19#define __R_TASK_QUEUE_H__
21#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
22#error "#include <rlib.h> only please."
78#define r_task_ref r_ref_ref
80#define r_task_unref r_ref_unref
143#define r_task_queue_ref r_ref_ref
145#define r_task_queue_unref r_ref_unref
172#define r_task_queue_add_task(queue, task) \
173 r_task_queue_add_task_with_group (queue, task, RUINT_MAX)
192#define r_task_queue_add(queue, func, data, datanotify) \
193 r_task_queue_add_full (queue, RUINT_MAX, func, data, datanotify, NULL)
#define R_ATTR_WARN_UNUSED_RESULT
Warn if a function's return value is ignored.
Definition rmacros.h:278
#define R_ATTR_NULL_TERMINATED
Mark a variadic function as requiring a NULL sentinel.
Definition rmacros.h:336
#define R_API
Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
Definition rmacros.h:115
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
rboolean r_task_cancel(RTask *task, rboolean wait_if_running)
Cancel a pending or running task.
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.
rboolean r_task_add_dep(RTask *task, RTask *dep,...)
Add one or more dependencies to a task that has not yet run.
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.
ruint r_task_queue_group_count(const RTaskQueue *queue)
Number of worker groups in queue.
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.
struct RTaskQueue RTaskQueue
Opaque, refcounted task-queue handle.
Definition rtaskqueue.h:67
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.
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_wait(RTask *task)
Block until task has finished (cancelled tasks count as finished).
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'...
struct RTask RTask
Opaque, refcounted task handle.
Definition rtaskqueue.h:65
rboolean r_task_queue_add_task_with_group(RTaskQueue *queue, RTask *task, ruint group)
Dispatch a pre-allocated task to a specific group.
rboolean r_task_add_dep_v(RTask *task, RTask *dep, va_list args)
va_list variant of r_task_add_dep.
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.
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.
ruint r_task_queue_thread_count(const RTaskQueue *queue)
Total number of worker threads across all groups.
RTaskQueue * r_task_queue_current(void)
Return the queue owning the calling thread, or NULL if the calling thread is not a queue worker.
void(* RTaskFunc)(rpointer data, RTaskQueue *queue, RTask *task)
Task entry-point signature.
Definition rtaskqueue.h:75
rsize r_task_queue_queued_tasks(const RTaskQueue *queue)
Number of tasks currently queued but not yet running.
int rboolean
Boolean type (typedef'd to int).
Definition rtypes.h:59
unsigned int ruint
Unsigned int.
Definition rtypes.h:157
void(* RDestroyNotify)(rpointer ptr)
Destructor callback: free / release the value at ptr.
Definition rtypes.h:401
void * rpointer
Generic pointer (alias for void *).
Definition rtypes.h:327
unsigned long rsize
Unsigned pointer-sized size type (like size_t).
Definition rtypes.h:290
Fixed-width bitset with bit / byte / word accessors and bitwise compound operations.
Refcount base struct shared by every refcounted type in rlib.
Foundational type aliases used by every rlib header.
Fixed-width bitset.
Definition rbitset.h:68