The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/os: Add a function to set thread name.

+33
+1
CMakeLists.txt
··· 123 123 set(CMAKE_THREAD_PREFER_PTHREAD ON) 124 124 find_package(Threads) 125 125 target_link_libraries(xrt-pthreads INTERFACE Threads::Threads) 126 + target_compile_definitions(xrt-pthreads INTERFACE _GNU_SOURCE) 126 127 endif() 127 128 128 129 if(PKGCONFIG_FOUND AND NOT ANDROID)
+32
src/xrt/auxiliary/os/os_threading.h
··· 21 21 #include <pthread.h> 22 22 #include <semaphore.h> 23 23 #include <assert.h> 24 + #define OS_THREAD_HAVE_SETNAME 24 25 #elif defined(XRT_OS_WINDOWS) 25 26 #include <pthread.h> 26 27 #include <sched.h> 27 28 #include <semaphore.h> 28 29 #include <assert.h> 30 + #define OS_THREAD_HAVE_SETNAME 29 31 #else 30 32 #error "OS not supported" 31 33 #endif ··· 201 203 os_thread_destroy(struct os_thread *ost) 202 204 {} 203 205 206 + /*! 207 + * Make a best effort to name our thread. 208 + * 209 + * @public @memberof os_thread 210 + */ 211 + static inline void 212 + os_thread_name(struct os_thread *ost, const char *name) 213 + { 214 + #ifdef OS_THREAD_HAVE_SETNAME 215 + pthread_setname_np(ost->thread, name); 216 + #else 217 + (void)ost; 218 + (void)name; 219 + #endif 220 + } 204 221 205 222 /* 206 223 * ··· 517 534 pthread_cond_signal(&oth->cond); 518 535 } 519 536 537 + /*! 538 + * Make a best effort to name our thread. 539 + * 540 + * @public @memberof os_thread_helper 541 + */ 542 + static inline void 543 + os_thread_helper_name(struct os_thread_helper *oth, const char *name) 544 + { 545 + #ifdef OS_THREAD_HAVE_SETNAME 546 + pthread_setname_np(oth->thread, name); 547 + #else 548 + (void)oth; 549 + (void)name; 550 + #endif 551 + } 520 552 521 553 /*! 522 554 * @}