Allow direct access to ThreadNameData.

This commit is contained in:
Bartosz Taudul 2024-08-03 19:33:19 +02:00
parent 3658c0c90f
commit 5e224101c4
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 26 additions and 7 deletions

View File

@ -101,13 +101,6 @@ TRACY_API uint32_t GetThreadHandleImpl()
}
#ifdef TRACY_ENABLE
struct ThreadNameData
{
uint32_t id;
uint32_t groupHint;
const char* name;
ThreadNameData* next;
};
std::atomic<ThreadNameData*>& GetThreadNameData();
#endif
@ -219,6 +212,22 @@ TRACY_API void SetThreadNameWithHint( const char* name, uint32_t groupHint )
#endif
}
#ifdef TRACY_ENABLE
ThreadNameData* GetThreadNameData( uint32_t id )
{
auto ptr = GetThreadNameData().load( std::memory_order_relaxed );
while( ptr )
{
if( ptr->id == id )
{
return ptr;
}
ptr = ptr->next;
}
return nullptr;
}
#endif
TRACY_API const char* GetThreadName( uint32_t id )
{
static char buf[256];

View File

@ -14,6 +14,16 @@ TRACY_API uint32_t GetThreadHandleImpl();
}
#ifdef TRACY_ENABLE
struct ThreadNameData
{
uint32_t id;
uint32_t groupHint;
const char* name;
ThreadNameData* next;
};
ThreadNameData* GetThreadNameData( uint32_t id );
TRACY_API uint32_t GetThreadHandle();
#else
static inline uint32_t GetThreadHandle()