| 100 | } |
| 101 | |
| 102 | void SetCurrentThreadDebugName(const char* name) { |
| 103 | #if defined(_DEBUG) |
| 104 | #if defined(_WIN32) |
| 105 | typedef struct tagTHREADNAME_INFO { |
| 106 | DWORD dwType; // Must be 0x1000. |
| 107 | LPCSTR szName; // Pointer to name (in user addr space). |
| 108 | DWORD dwThreadID; // Thread ID (-1=caller thread). |
| 109 | DWORD dwFlags; // Reserved for future use, must be zero. |
| 110 | } THREADNAME_INFO; |
| 111 | |
| 112 | THREADNAME_INFO info; |
| 113 | info.dwType = 0x1000; |
| 114 | info.szName = name; |
| 115 | info.dwThreadID = GetCurrentThreadId(); |
| 116 | info.dwFlags = 0; |
| 117 | |
| 118 | __try { |
| 119 | RaiseException(0x406D1388, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info); |
| 120 | } __except (EXCEPTION_EXECUTE_HANDLER) { |
| 121 | } |
| 122 | |
| 123 | #elif defined(_OS_BSD) |
| 124 | pthread_set_name_np(pthread_self(), name); |
| 125 | #else |
| 126 | prctl(PR_SET_NAME, name, 0, 0, 0); |
| 127 | #endif |
| 128 | #endif |
| 129 | } |
| 130 | |
| 131 | void Util::SetCurrentThreadName(const char* name) { |
| 132 | SetCurrentThreadDebugName(name); |
no outgoing calls
no test coverage detected