diff --git a/include/bx/thread.h b/include/bx/thread.h index f7db4af..6d78bc5 100644 --- a/include/bx/thread.h +++ b/include/bx/thread.h @@ -72,6 +72,7 @@ namespace bx uint32_t m_stackSize; int32_t m_exitCode; bool m_running; + char m_name[32]; }; /// diff --git a/src/thread.cpp b/src/thread.cpp index 2729636..9a0f2fb 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -132,6 +132,15 @@ namespace bx m_userData = _userData; m_stackSize = _stackSize; + if (NULL != _name) + { + strCopy(m_name, sizeof(m_name), _name); + } + else + { + m_name[0] = '\0'; + } + ThreadInternal* ti = (ThreadInternal*)m_internal; #if BX_CRT_NONE ti->m_handle = crt0::threadCreate(&ti->threadFunc, _userData, m_stackSize, _name); @@ -190,11 +199,6 @@ namespace bx m_running = true; m_sem.wait(); - if (NULL != _name) - { - setThreadName(_name); - } - return true; } @@ -316,6 +320,7 @@ namespace bx #endif // BX_PLATFORM_WINDOWS m_sem.post(); + setThreadName(m_name); int32_t result = m_fn(this, m_userData); return result; }