Branimir Karadžić 10 lat temu
rodzic
commit
bbbd526231
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      include/bx/thread.h

+ 7 - 1
include/bx/thread.h

@@ -52,7 +52,7 @@ namespace bx
 			}
 			}
 		}
 		}
 
 
-		void init(ThreadFn _fn, void* _userData = NULL, uint32_t _stackSize = 0)
+		void init(ThreadFn _fn, void* _userData = NULL, uint32_t _stackSize = 0, const char* _name = NULL)
 		{
 		{
 			BX_CHECK(!m_running, "Already running!");
 			BX_CHECK(!m_running, "Already running!");
 
 
@@ -101,6 +101,10 @@ namespace bx
 			BX_CHECK(0 == result, "pthread_attr_setschedparam failed! %d", result);
 			BX_CHECK(0 == result, "pthread_attr_setschedparam failed! %d", result);
 #endif // BX_PLATFORM_
 #endif // BX_PLATFORM_
 
 
+			if (NULL != _name)
+			{
+				setThreadName(_name);
+			}
 			m_sem.wait();
 			m_sem.wait();
 		}
 		}
 
 
@@ -146,6 +150,7 @@ namespace bx
 #elif BX_PLATFORM_POSIX
 #elif BX_PLATFORM_POSIX
 			pthread_setname_np(m_handle, _name);
 			pthread_setname_np(m_handle, _name);
 #elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
 #elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
+#	pragma pack(push, 8)
 			struct ThreadName
 			struct ThreadName
 			{
 			{
 				DWORD  type;
 				DWORD  type;
@@ -153,6 +158,7 @@ namespace bx
 				DWORD  id;
 				DWORD  id;
 				DWORD  flags;
 				DWORD  flags;
 			};
 			};
+#	pragma pack(pop)
 			ThreadName tn;
 			ThreadName tn;
 			tn.type  = 0x1000;
 			tn.type  = 0x1000;
 			tn.name  = _name;
 			tn.name  = _name;