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

Add thread group hint to ThreadNameData.

This commit is contained in:
Bartosz Taudul 2024-08-03 19:15:01 +02:00
parent fb18a81d79
commit 3658c0c90f
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 8 additions and 0 deletions

View File

@ -104,6 +104,7 @@ TRACY_API uint32_t GetThreadHandleImpl()
struct ThreadNameData
{
uint32_t id;
uint32_t groupHint;
const char* name;
ThreadNameData* next;
};
@ -134,6 +135,11 @@ void ThreadNameMsvcMagic( const THREADNAME_INFO& info )
#endif
TRACY_API void SetThreadName( const char* name )
{
SetThreadNameWithHint( name, 0 );
}
TRACY_API void SetThreadNameWithHint( const char* name, uint32_t groupHint )
{
#if defined _WIN32
# ifdef TRACY_UWP
@ -205,6 +211,7 @@ TRACY_API void SetThreadName( const char* name )
buf[sz] = '\0';
auto data = (ThreadNameData*)tracy_malloc_fast( sizeof( ThreadNameData ) );
data->id = detail::GetThreadHandleImpl();
data->groupHint = groupHint;
data->name = buf;
data->next = GetThreadNameData().load( std::memory_order_relaxed );
while( !GetThreadNameData().compare_exchange_weak( data->next, data, std::memory_order_release, std::memory_order_relaxed ) ) {}

View File

@ -23,6 +23,7 @@ static inline uint32_t GetThreadHandle()
#endif
TRACY_API void SetThreadName( const char* name );
TRACY_API void SetThreadNameWithHint( const char* name, uint32_t groupHint );
TRACY_API const char* GetThreadName( uint32_t id );
TRACY_API const char* GetEnvVar( const char* name );