We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ae5b6bd + 8d4d2fa commit d44fdd9Copy full SHA for d44fdd9
util/thread_name.cpp
@@ -22,7 +22,7 @@
22
23
#include "thread_name.hpp"
24
25
-#ifdef __linux__
+#if !defined(_WIN32)
26
#include <pthread.h>
27
#else
28
#define WIN32_LEAN_AND_MEAN
@@ -34,9 +34,11 @@ namespace Util
34
{
35
void set_current_thread_name(const char *name)
36
37
+#if defined(__linux__)
38
pthread_setname_np(pthread_self(), name);
39
-#else
+#elif defined(__APPLE__)
40
+ pthread_setname_np(name);
41
+#elif defined(_WIN32)
42
using PFN_SetThreadDescription = HRESULT (WINAPI *)(HANDLE, PCWSTR);
43
auto module = GetModuleHandleA("kernel32.dll");
44
PFN_SetThreadDescription SetThreadDescription = module ? reinterpret_cast<PFN_SetThreadDescription>(
@@ -54,4 +56,4 @@ void set_current_thread_name(const char *name)
54
56
}
55
57
#endif
58
-}
59
+}
0 commit comments