MCPcopy Create free account
hub / github.com/defold/defold / GetThreadId

Function GetThreadId

engine/profiler/src/basic/profiler_basic.cpp:324–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322// Threads
323
324static int32_t GetThreadId()
325{
326 void* tls_data = (ThreadData*)dmThread::GetTlsValue(g_TlsKey);
327 if (tls_data == 0)
328 {
329 // NOTE: We store thread_id + 1. Otherwise we can't differentiate between thread-id 0 and not initialized
330 int32_t next_thread_id = dmAtomicIncrement32(&g_ThreadCount) + 1;
331 tls_data = (void*)((uintptr_t)next_thread_id);
332 dmThread::SetTlsValue(g_TlsKey, tls_data);
333 }
334
335 intptr_t thread_id = ((intptr_t)tls_data) - 1;
336 assert(thread_id >= 0);
337 return (int32_t)thread_id;
338}
339
340static const char* GetThreadName(int32_t thread_id)
341{

Callers 3

SetThreadNameFunction · 0.70
ScopeBeginFunction · 0.70
ScopeEndFunction · 0.70

Calls 4

dmAtomicIncrement32Function · 0.85
GetTlsValueFunction · 0.50
SetTlsValueFunction · 0.50
assertFunction · 0.50

Tested by

no test coverage detected