20namespace xrt::auxiliary::util {
23class SharedThreadGroup;
54 SharedThreadPool(uint32_t starting_worker_count, uint32_t thread_count,
const char *prefix)
65 operator=(
const SharedThreadPool &other)
75 friend SharedThreadGroup;
78 SharedThreadPool() =
delete;
80 SharedThreadPool(SharedThreadPool &&) =
delete;
83 operator=(SharedThreadPool &&) =
delete;
130 typedef std::function<void()> Functor;
134 static constexpr size_t kSize = 16;
136 Functor mFunctors[kSize] = {};
147 assert(funcs.size() <= kSize);
151 for (
size_t i = 0; i < kSize && i < funcs.size(); i++) {
152 mFunctors[i] = funcs[i];
169 if (mGroup ==
nullptr) {
188 cCallback(
void *data_ptr);
Wrapper around u_worker_group, use TaskCollection to dispatch work.
Definition: u_worker.hpp:92
Wrapper around u_worker_thread_pool.
Definition: u_worker.hpp:31
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:54
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:46
Class to let users fall into a pit of success by being designed as a one shot dispatcher instance.
Definition: u_worker.hpp:128
void waitAll()
Waits for all given tasks to complete, also frees the group.
Definition: u_worker.hpp:167
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:145
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:525
struct u_worker_group * u_worker_group_create(struct u_worker_thread_pool *uwtp)
Create a new worker group.
Definition: u_worker.c:483
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:399
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:497
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.