Hide rest of statics.

This commit is contained in:
Bartosz Taudul
2019-02-19 19:33:37 +01:00
parent 9fabafbeca
commit 3f914834b7
8 changed files with 112 additions and 132 deletions

View File

@@ -44,7 +44,7 @@ struct ThreadNameData
const char* name;
ThreadNameData* next;
};
extern std::atomic<ThreadNameData*>& s_threadNameData;
std::atomic<ThreadNameData*>& GetThreadNameData();
#endif
void SetThreadName( std::thread& thread, const char* name )
@@ -124,8 +124,8 @@ void SetThreadName( std::thread::native_handle_type handle, const char* name )
data->id = (uint64_t)handle;
# endif
data->name = buf;
data->next = s_threadNameData.load( std::memory_order_relaxed );
while( !s_threadNameData.compare_exchange_weak( data->next, data, std::memory_order_release, std::memory_order_relaxed ) ) {}
data->next = GetThreadNameData().load( std::memory_order_relaxed );
while( !GetThreadNameData().compare_exchange_weak( data->next, data, std::memory_order_release, std::memory_order_relaxed ) ) {}
}
#endif
}
@@ -134,7 +134,7 @@ const char* GetThreadName( uint64_t id )
{
static char buf[256];
#ifdef TRACY_COLLECT_THREAD_NAMES
auto ptr = s_threadNameData.load( std::memory_order_relaxed );
auto ptr = GetThreadNameData().load( std::memory_order_relaxed );
while( ptr )
{
if( ptr->id == id )