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

Function SetThreadName

engine/dlib/src/dlib/thread_win32.cpp:31–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 typedef HRESULT (*PfnSetThreadDescription)(HANDLE,PCWSTR);
30
31 void SetThreadName(Thread thread, const char* name)
32 {
33 (void)thread;
34 (void)name;
35 // Currently, this crashed mysteriously on Win32, so we'll keep it only for Win64 until we've figured it out
36 #if defined(_WIN64)
37 static PfnSetThreadDescription pfn = (PfnSetThreadDescription)GetFunctionPtr("kernel32.dll", "SetThreadDescription");
38 if (pfn) {
39 size_t wn = mbsrtowcs(NULL, &name, 0, NULL);
40 wchar_t* buf = (wchar_t*)malloc((wn + 1) * sizeof(wchar_t));
41 wn = mbsrtowcs(buf, &name, wn + 1, NULL);
42
43 pfn(thread, buf);
44
45 free(buf);
46 }
47 #endif
48 }
49
50 Thread New(ThreadStart thread_start, uint32_t stack_size, void* arg, const char* name)
51 {

Callers 4

NewFunction · 0.70
EngineMainThreadFunction · 0.50
engine_mainFunction · 0.50
dmEngineInitializeFunction · 0.50

Calls 3

GetFunctionPtrFunction · 0.85
mallocFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected