Further attempts at fixing segfault in locks

This commit is contained in:
Deukhoofd 2022-02-11 13:29:30 +01:00
parent ee2f629911
commit dd93ba7ec4
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 8 additions and 4 deletions

View File

@ -198,7 +198,7 @@ public:
bool TryEnter(); bool TryEnter();
protected: protected:
std::unique_ptr<std::mutex> _mutex; std::mutex* _mutex;
}; };
class asCThreadReadWriteLock class asCThreadReadWriteLock
@ -215,7 +215,7 @@ public:
void ReleaseShared(); void ReleaseShared();
bool TryAcquireShared(); bool TryAcquireShared();
protected: protected:
std::unique_ptr<std::shared_mutex> _mutex; std::shared_mutex* _mutex;
}; };
#endif #endif

View File

@ -350,7 +350,7 @@ asCThreadCriticalSection::asCThreadCriticalSection()
InitializeCriticalSection(&cs); InitializeCriticalSection(&cs);
#endif #endif
#elif defined AS_STD_THREADS #elif defined AS_STD_THREADS
_mutex = std::make_unique<std::mutex>(); _mutex = new std::mutex();
#endif #endif
} }
@ -360,6 +360,8 @@ asCThreadCriticalSection::~asCThreadCriticalSection()
pthread_mutex_destroy(&cs); pthread_mutex_destroy(&cs);
#elif defined AS_WINDOWS_THREADS #elif defined AS_WINDOWS_THREADS
DeleteCriticalSection(&cs); DeleteCriticalSection(&cs);
#elif defined AS_STD_THREADS
delete _mutex;
#endif #endif
} }
@ -417,7 +419,7 @@ asCThreadReadWriteLock::asCThreadReadWriteLock()
InitializeCriticalSection(&writeLock); InitializeCriticalSection(&writeLock);
#endif #endif
#elif defined AS_STD_THREADS #elif defined AS_STD_THREADS
_mutex = std::make_unique<std::shared_mutex>(); _mutex = new std::shared_mutex();
#endif #endif
} }
@ -428,6 +430,8 @@ asCThreadReadWriteLock::~asCThreadReadWriteLock()
#elif defined AS_WINDOWS_THREADS #elif defined AS_WINDOWS_THREADS
DeleteCriticalSection(&writeLock); DeleteCriticalSection(&writeLock);
CloseHandle(readLocks); CloseHandle(readLocks);
#elif defined AS_STD_THREADS
delete _mutex;
#endif #endif
} }