From 9c84058e1b1295f7b6a7226893abb2759ef1eabc Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 11 Feb 2022 13:42:28 +0100 Subject: [PATCH] Revert "Further attempts at fixing segfault in locks" This reverts commit dd93ba7ec443bd22d05c33f3aed5d538a6505d0c. --- angelscript/source/as_criticalsection.h | 4 ++-- angelscript/source/as_thread.cpp | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/angelscript/source/as_criticalsection.h b/angelscript/source/as_criticalsection.h index 7915e46..b05c224 100644 --- a/angelscript/source/as_criticalsection.h +++ b/angelscript/source/as_criticalsection.h @@ -198,7 +198,7 @@ public: bool TryEnter(); protected: - std::mutex* _mutex; + std::unique_ptr _mutex; }; class asCThreadReadWriteLock @@ -215,7 +215,7 @@ public: void ReleaseShared(); bool TryAcquireShared(); protected: - std::shared_mutex* _mutex; + std::unique_ptr _mutex; }; #endif diff --git a/angelscript/source/as_thread.cpp b/angelscript/source/as_thread.cpp index 25066d3..83f7e22 100644 --- a/angelscript/source/as_thread.cpp +++ b/angelscript/source/as_thread.cpp @@ -350,7 +350,7 @@ asCThreadCriticalSection::asCThreadCriticalSection() InitializeCriticalSection(&cs); #endif #elif defined AS_STD_THREADS - _mutex = new std::mutex(); + _mutex = std::make_unique(); #endif } @@ -360,8 +360,6 @@ asCThreadCriticalSection::~asCThreadCriticalSection() pthread_mutex_destroy(&cs); #elif defined AS_WINDOWS_THREADS DeleteCriticalSection(&cs); -#elif defined AS_STD_THREADS - delete _mutex; #endif } @@ -419,7 +417,7 @@ asCThreadReadWriteLock::asCThreadReadWriteLock() InitializeCriticalSection(&writeLock); #endif #elif defined AS_STD_THREADS - _mutex = new std::shared_mutex(); + _mutex = std::make_unique(); #endif } @@ -430,8 +428,6 @@ asCThreadReadWriteLock::~asCThreadReadWriteLock() #elif defined AS_WINDOWS_THREADS DeleteCriticalSection(&writeLock); CloseHandle(readLocks); -#elif defined AS_STD_THREADS - delete _mutex; #endif }