| 322 | // Threads |
| 323 | |
| 324 | static 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 | |
| 340 | static const char* GetThreadName(int32_t thread_id) |
| 341 | { |
no test coverage detected