GetThreadHandle() might be used by application's code.

This commit is contained in:
Bartosz Taudul 2019-06-25 15:44:49 +02:00
parent 0b656c3469
commit bc7f2c49c8
2 changed files with 11 additions and 3 deletions

View File

@ -928,7 +928,7 @@ enum { BulkSize = TargetFrameSize / QueueItemSize };
Profiler::Profiler() Profiler::Profiler()
: m_timeBegin( 0 ) : m_timeBegin( 0 )
, m_mainThread( GetThreadHandleImpl() ) , m_mainThread( detail::GetThreadHandleImpl() )
, m_epoch( std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch() ).count() ) , m_epoch( std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch() ).count() )
, m_shutdown( false ) , m_shutdown( false )
, m_shutdownManual( false ) , m_shutdownManual( false )

View File

@ -23,7 +23,8 @@ extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void
namespace tracy namespace tracy
{ {
#ifdef TRACY_ENABLE namespace detail
{
static inline uint64_t GetThreadHandleImpl() static inline uint64_t GetThreadHandleImpl()
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -38,13 +39,20 @@ static inline uint64_t GetThreadHandleImpl()
return uint64_t( pthread_self() ); return uint64_t( pthread_self() );
#endif #endif
} }
}
const thread_local auto s_threadHandle = GetThreadHandleImpl(); #ifdef TRACY_ENABLE
const thread_local auto s_threadHandle = detail::GetThreadHandleImpl();
static inline uint64_t GetThreadHandle() static inline uint64_t GetThreadHandle()
{ {
return s_threadHandle; return s_threadHandle;
} }
#else
static inline uint64_t GetThreadHandle()
{
return detail::GetThreadHandleImpl();
}
#endif #endif
void SetThreadName( std::thread& thread, const char* name ); void SetThreadName( std::thread& thread, const char* name );