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

Function GetThreadId

engine/profiler/src/js/profiler_js.cpp:158–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156// Threads
157
158static int32_t GetThreadId()
159{
160 void* tls_data = (ThreadData*)dmThread::GetTlsValue(g_TlsKey);
161 if (tls_data == 0)
162 {
163 // NOTE: We store thread_id + 1. Otherwise we can't differentiate between thread-id 0 and not initialized
164 int32_t next_thread_id = dmAtomicIncrement32(&g_ThreadCount) + 1;
165 tls_data = (void*)((uintptr_t)next_thread_id);
166 dmThread::SetTlsValue(g_TlsKey, tls_data);
167 }
168
169 intptr_t thread_id = ((intptr_t)tls_data) - 1;
170 assert(thread_id >= 0);
171 return (int32_t)thread_id;
172}
173
174///////////////////////////////////////////////////////////////////////////////////////////////
175

Callers 4

SetThreadNameFunction · 0.70
FrameEndFunction · 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