21namespace xrt::auxiliary::util {
24class SharedThreadGroup;
55 SharedThreadPool(uint32_t starting_worker_count, uint32_t thread_count,
const char *prefix)
66 operator=(
const SharedThreadPool &other)
76 friend SharedThreadGroup;
79 SharedThreadPool() =
delete;
81 SharedThreadPool(SharedThreadPool &&) =
delete;
84 operator=(SharedThreadPool &&) =
delete;
142 typedef std::function<void()> Functor;
146 static constexpr size_t kSize = 16;
148 Functor mFunctors[kSize] = {};
159 assert(funcs.size() <= kSize);
163 for (
size_t i = 0; i < kSize && i < funcs.size(); i++) {
164 mFunctors[i] = funcs[i];
181 if (mGroup ==
nullptr) {
200 cCallback(
void *data_ptr);
Wrapper around u_worker_group, use TaskCollection to dispatch work.
Definition: u_worker.hpp:93
void push(u_worker_group_func_t f, void *data)
In-general it's recommended to use the TaskCollection helper, but some use cases requires direct acce...
Definition: u_worker.hpp:115
Wrapper around u_worker_thread_pool.
Definition: u_worker.hpp:32
SharedThreadPool(uint32_t starting_worker_count, uint32_t thread_count, const char *prefix)
Creates a new thread pool to be used by a worker group.
Definition: u_worker.hpp:55
SharedThreadPool(u_worker_thread_pool *uwtp)
Take a C thread pool as argument in case the pool is shared between different C++ components over C i...
Definition: u_worker.hpp:47
Class to let users fall into a pit of success by being designed as a one shot dispatcher instance.
Definition: u_worker.hpp:140
void waitAll()
Waits for all given tasks to complete, also frees the group.
Definition: u_worker.hpp:179
TaskCollection(SharedThreadGroup const &stc, std::vector< Functor > const &funcs)
Give all Functors when constructed, some what partially avoids use after leaving scope issues of func...
Definition: u_worker.hpp:157
void(* u_worker_group_func_t)(void *)
Function typedef for tasks.
Definition: u_worker.h:111
void u_worker_group_wait_all(struct u_worker_group *uwg)
Wait for all pushed tasks to be completed, "donates" this thread to the shared thread pool.
Definition: u_worker.c:545
struct u_worker_group * u_worker_group_create(struct u_worker_thread_pool *uwtp)
Create a new worker group.
Definition: u_worker.c:503
static void u_worker_thread_pool_reference(struct u_worker_thread_pool **dst, struct u_worker_thread_pool *src)
Standard Monado reference function.
Definition: u_worker.h:67
static void u_worker_group_reference(struct u_worker_group **dst, struct u_worker_group *src)
Standard Monado reference function.
Definition: u_worker.h:152
struct u_worker_thread_pool * u_worker_thread_pool_create(uint32_t starting_worker_count, uint32_t thread_count, const char *prefix)
Creates a new thread pool to be used by a worker group.
Definition: u_worker.c:419
void u_worker_group_push(struct u_worker_group *uwg, u_worker_group_func_t f, void *data)
Push a new task to worker group.
Definition: u_worker.c:517
A worker group where you submit tasks to.
Definition: u_worker.h:102
A worker pool, can shared between multiple groups worker pool.
Definition: u_worker.h:33
Worker and threading pool.