mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Use winapi function to set thread name.
Fairly recent Windows SDK is required, unfortunately.
This commit is contained in:
parent
8a30e1c937
commit
0c0b18615a
@ -16,32 +16,9 @@ const char* PointerCheckA = "tracy";
|
|||||||
void SetThreadName( std::thread& thread, const char* name )
|
void SetThreadName( std::thread& thread, const char* name )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const DWORD MS_VC_EXCEPTION=0x406D1388;
|
wchar_t buf[256];
|
||||||
|
mbstowcs( buf, name, 256 );
|
||||||
# pragma pack( push, 8 )
|
SetThreadDescription( static_cast<HANDLE>( thread.native_handle() ), buf );
|
||||||
struct THREADNAME_INFO
|
|
||||||
{
|
|
||||||
DWORD dwType;
|
|
||||||
LPCSTR szName;
|
|
||||||
DWORD dwThreadID;
|
|
||||||
DWORD dwFlags;
|
|
||||||
};
|
|
||||||
# pragma pack(pop)
|
|
||||||
|
|
||||||
DWORD ThreadId = GetThreadId( static_cast<HANDLE>( thread.native_handle() ) );
|
|
||||||
THREADNAME_INFO info;
|
|
||||||
info.dwType = 0x1000;
|
|
||||||
info.szName = name;
|
|
||||||
info.dwThreadID = ThreadId;
|
|
||||||
info.dwFlags = 0;
|
|
||||||
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
|
|
||||||
}
|
|
||||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
pthread_setname_np( thread.native_handle(), name );
|
pthread_setname_np( thread.native_handle(), name );
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user