fixes osx/ios set thread name (#284)

This commit is contained in:
actboy168
2024-05-12 10:45:31 +08:00
committed by GitHub
parent 2690b0da17
commit 98c43d8765
2 changed files with 11 additions and 5 deletions

View File

@@ -72,6 +72,7 @@ namespace bx
uint32_t m_stackSize; uint32_t m_stackSize;
int32_t m_exitCode; int32_t m_exitCode;
bool m_running; bool m_running;
char m_name[32];
}; };
/// ///

View File

@@ -132,6 +132,15 @@ namespace bx
m_userData = _userData; m_userData = _userData;
m_stackSize = _stackSize; m_stackSize = _stackSize;
if (NULL != _name)
{
strCopy(m_name, sizeof(m_name), _name);
}
else
{
m_name[0] = '\0';
}
ThreadInternal* ti = (ThreadInternal*)m_internal; ThreadInternal* ti = (ThreadInternal*)m_internal;
#if BX_CRT_NONE #if BX_CRT_NONE
ti->m_handle = crt0::threadCreate(&ti->threadFunc, _userData, m_stackSize, _name); ti->m_handle = crt0::threadCreate(&ti->threadFunc, _userData, m_stackSize, _name);
@@ -190,11 +199,6 @@ namespace bx
m_running = true; m_running = true;
m_sem.wait(); m_sem.wait();
if (NULL != _name)
{
setThreadName(_name);
}
return true; return true;
} }
@@ -316,6 +320,7 @@ namespace bx
#endif // BX_PLATFORM_WINDOWS #endif // BX_PLATFORM_WINDOWS
m_sem.post(); m_sem.post();
setThreadName(m_name);
int32_t result = m_fn(this, m_userData); int32_t result = m_fn(this, m_userData);
return result; return result;
} }