瀏覽代碼

Lazy init default thread allocator.

Branimir Karadžić 8 年之前
父節點
當前提交
5fdeb85157
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/thread.cpp

+ 6 - 2
src/thread.cpp

@@ -36,7 +36,11 @@ using namespace Windows::System::Threading;
 
 
 namespace bx
 namespace bx
 {
 {
-	static DefaultAllocator s_allocator;
+	static AllocatorI* getAllocator()
+	{
+		static DefaultAllocator s_allocator;
+		return &s_allocator;
+	}
 
 
 	struct ThreadInternal
 	struct ThreadInternal
 	{
 	{
@@ -78,7 +82,7 @@ namespace bx
 	Thread::Thread()
 	Thread::Thread()
 		: m_fn(NULL)
 		: m_fn(NULL)
 		, m_userData(NULL)
 		, m_userData(NULL)
-		, m_queue(&s_allocator)
+		, m_queue(getAllocator() )
 		, m_stackSize(0)
 		, m_stackSize(0)
 		, m_exitCode(kExitSuccess)
 		, m_exitCode(kExitSuccess)
 		, m_running(false)
 		, m_running(false)