mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
u/worker: Use U_TRACE_SET_THREAD_NAME
This commit is contained in:
parent
8b0e7675e4
commit
d48de0d832
|
@ -40,6 +40,9 @@ struct thread
|
||||||
|
|
||||||
// Native thread.
|
// Native thread.
|
||||||
struct os_thread thread;
|
struct os_thread thread;
|
||||||
|
|
||||||
|
//! Thread name.
|
||||||
|
char name[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pool
|
struct pool
|
||||||
|
@ -78,6 +81,9 @@ struct pool
|
||||||
|
|
||||||
//! Is the pool up and running?
|
//! Is the pool up and running?
|
||||||
bool running;
|
bool running;
|
||||||
|
|
||||||
|
//! Prefix to use for thread names.
|
||||||
|
char prefix[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct group
|
struct group
|
||||||
|
@ -335,6 +341,9 @@ run_func(void *ptr)
|
||||||
struct thread *t = (struct thread *)ptr;
|
struct thread *t = (struct thread *)ptr;
|
||||||
struct pool *p = t->p;
|
struct pool *p = t->p;
|
||||||
|
|
||||||
|
snprintf(t->name, sizeof(t->name), "%s: Worker", p->prefix);
|
||||||
|
U_TRACE_SET_THREAD_NAME(t->name);
|
||||||
|
|
||||||
os_mutex_lock(&p->mutex);
|
os_mutex_lock(&p->mutex);
|
||||||
|
|
||||||
while (p->running) {
|
while (p->running) {
|
||||||
|
@ -387,7 +396,7 @@ run_func(void *ptr)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct u_worker_thread_pool *
|
struct u_worker_thread_pool *
|
||||||
u_worker_thread_pool_create(uint32_t starting_worker_count, uint32_t thread_count)
|
u_worker_thread_pool_create(uint32_t starting_worker_count, uint32_t thread_count, const char *prefix)
|
||||||
{
|
{
|
||||||
XRT_TRACE_MARKER();
|
XRT_TRACE_MARKER();
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -408,6 +417,7 @@ u_worker_thread_pool_create(uint32_t starting_worker_count, uint32_t thread_coun
|
||||||
p->worker_limit = starting_worker_count;
|
p->worker_limit = starting_worker_count;
|
||||||
p->thread_count = thread_count;
|
p->thread_count = thread_count;
|
||||||
p->running = true;
|
p->running = true;
|
||||||
|
snprintf(p->prefix, sizeof(p->prefix), "%s", prefix);
|
||||||
|
|
||||||
ret = os_mutex_init(&p->mutex);
|
ret = os_mutex_init(&p->mutex);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
|
|
@ -42,11 +42,13 @@ struct u_worker_thread_pool
|
||||||
* @param thread_count The number of threads to be created in total,
|
* @param thread_count The number of threads to be created in total,
|
||||||
* this is the maximum threads that can be in
|
* this is the maximum threads that can be in
|
||||||
* flight at the same time.
|
* flight at the same time.
|
||||||
|
* @param prefix Prefix to used when naming threads, used for
|
||||||
|
* tracing and debugging.
|
||||||
*
|
*
|
||||||
* @ingroup aux_util
|
* @ingroup aux_util
|
||||||
*/
|
*/
|
||||||
struct u_worker_thread_pool *
|
struct u_worker_thread_pool *
|
||||||
u_worker_thread_pool_create(uint32_t starting_worker_count, uint32_t thread_count);
|
u_worker_thread_pool_create(uint32_t starting_worker_count, uint32_t thread_count, const char *prefix);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Internal function, only called by reference.
|
* Internal function, only called by reference.
|
||||||
|
|
|
@ -51,9 +51,9 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* @copydoc u_worker_thread_pool_create
|
* @copydoc u_worker_thread_pool_create
|
||||||
*/
|
*/
|
||||||
SharedThreadPool(uint32_t starting_worker_count, uint32_t thread_count)
|
SharedThreadPool(uint32_t starting_worker_count, uint32_t thread_count, const char *prefix)
|
||||||
{
|
{
|
||||||
mPool = u_worker_thread_pool_create(starting_worker_count, thread_count);
|
mPool = u_worker_thread_pool_create(starting_worker_count, thread_count, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
~SharedThreadPool()
|
~SharedThreadPool()
|
||||||
|
|
|
@ -1047,7 +1047,7 @@ t_hand_tracking_sync_mercury_create(struct t_stereo_camera_calibration *calib,
|
||||||
hgt->views[1].view = 1;
|
hgt->views[1].view = 1;
|
||||||
|
|
||||||
int num_threads = 4;
|
int num_threads = 4;
|
||||||
hgt->pool = u_worker_thread_pool_create(num_threads - 1, num_threads);
|
hgt->pool = u_worker_thread_pool_create(num_threads - 1, num_threads, "Hand Tracking");
|
||||||
hgt->group = u_worker_group_create(hgt->pool);
|
hgt->group = u_worker_group_create(hgt->pool);
|
||||||
|
|
||||||
lm::optimizer_create(hgt->left_in_right, false, hgt->log_level, &hgt->kinematic_hands[0]);
|
lm::optimizer_create(hgt->left_in_right, false, hgt->log_level, &hgt->kinematic_hands[0]);
|
||||||
|
|
|
@ -20,7 +20,7 @@ using namespace xrt::auxiliary::util;
|
||||||
|
|
||||||
TEST_CASE("TaskCollection")
|
TEST_CASE("TaskCollection")
|
||||||
{
|
{
|
||||||
SharedThreadPool pool{2, 3};
|
SharedThreadPool pool{2, 3, "Test"};
|
||||||
bool calledA[] = {
|
bool calledA[] = {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
|
Loading…
Reference in a new issue