1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Do the same trick as concurrentqueue.h for GetCurrentThreadId().

This commit is contained in:
Bartosz Taudul 2017-09-26 00:46:46 +02:00
parent 1c4dcf7e52
commit 809d98162b
2 changed files with 17 additions and 12 deletions

View File

@ -13,17 +13,6 @@
namespace tracy
{
uint64_t GetThreadHandle()
{
#ifdef _MSC_VER
static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
return uint64_t( GetCurrentThreadId() );
#else
static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
return uint64_t( pthread_self() );
#endif
}
void SetThreadName( std::thread& thread, const char* name )
{
#ifdef _WIN32

View File

@ -1,13 +1,29 @@
#ifndef __TRACYSYSTEM_HPP__
#define __TRACYSYSTEM_HPP__
#ifdef _WIN32
extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void);
#else
# include <pthread.h>
#endif
#include <stdint.h>
#include <thread>
namespace tracy
{
uint64_t GetThreadHandle();
static inline uint64_t GetThreadHandle()
{
#ifdef _WIN32
static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
return uint64_t( GetCurrentThreadId() );
#else
static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
return uint64_t( pthread_self() );
#endif
}
void SetThreadName( std::thread& thread, const char* name );
const char* GetThreadName( uint64_t id );