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

Function TlsThreadFunction

engine/dlib/src/test/test_thread.cpp:59–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57int32_atomic_t g_NextTlsIndex = 0;
58
59static void TlsThreadFunction(void* arg)
60{
61 uintptr_t n = (uintptr_t) arg;
62
63 void* data = dmThread::GetTlsValue(g_TlsKey);
64 assert(data == 0);
65 int32_t i = dmAtomicIncrement32(&g_NextTlsIndex);
66 data = &g_TlsData[i];
67 dmThread::SetTlsValue(g_TlsKey, data);
68
69 for (uintptr_t i = 0; i < n; ++i)
70 {
71 int* tls_data = (int*) dmThread::GetTlsValue(g_TlsKey);
72 *tls_data = *tls_data + 1;
73 }
74}
75
76TEST(Thread, Tls)
77{

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected