From 9f34f1494d22b36c358ce260ed6b40b644ee4a6e Mon Sep 17 00:00:00 2001 From: Aidan Lee Date: Sun, 22 Mar 2026 15:56:34 +0000 Subject: [PATCH] use a recursive mutex for the thread state change lock --- src/hx/gc/Immix.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hx/gc/Immix.cpp b/src/hx/gc/Immix.cpp index 0f7b41c6b..4e5fd24f4 100644 --- a/src/hx/gc/Immix.cpp +++ b/src/hx/gc/Immix.cpp @@ -394,7 +394,7 @@ static int sgTimeToNextTableUpdate = 1; -std::mutex *gThreadStateChangeLock=nullptr; +std::recursive_mutex *gThreadStateChangeLock=nullptr; std::mutex *gSpecialObjectLock=nullptr; class LocalAllocator; @@ -3133,12 +3133,12 @@ class GlobalAllocator { if (!gThreadStateChangeLock) { - gThreadStateChangeLock = new std::mutex(); + gThreadStateChangeLock = new std::recursive_mutex(); gSpecialObjectLock = new std::mutex(); } // Until we add ourselves, the collector will not wait // on us - ie, we are assumed ot be in a GC free zone. - std::lock_guard lock(*gThreadStateChangeLock); + std::lock_guard lock(*gThreadStateChangeLock); mLocalAllocs.push(inAlloc); // TODO Attach debugger } @@ -3161,7 +3161,7 @@ class GlobalAllocator LocalAllocator *GetPooledAllocator() { - std::lock_guard lock(*gThreadStateChangeLock); + std::lock_guard lock(*gThreadStateChangeLock); for(int p=0;p lock(*gThreadStateChangeLock); + std::lock_guard lock(*gThreadStateChangeLock); #ifdef HX_WINDOWS mID = 0; @@ -6084,7 +6084,7 @@ class LocalAllocator : public hx::StackContext if (!mGCFreeZone) CriticalGCError("GCFree Zone mismatch"); - std::lock_guard lock(*gThreadStateChangeLock); + std::lock_guard lock(*gThreadStateChangeLock); mReadyForCollect.Reset(); mGCFreeZone = false; #endif