[redcode/crythread-2nd-pass] replaced remaining CrySpinLock/CryWriteLock usage with equivalent AZStd version

Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
AMZN-ScottR
2021-08-11 15:54:59 -07:00
parent 6c83dcd702
commit 5a891c8cbd
3 changed files with 13 additions and 33 deletions
+5 -28
View File
@@ -21,7 +21,7 @@
//
//---------------------------------------------------------------------------
#include "MultiThread.h"
#include <AzCore/std/parallel/spin_mutex.h>
namespace stl
{
@@ -51,43 +51,20 @@ namespace stl
struct PSyncMultiThread
{
PSyncMultiThread()
: _Semaphore(0) {}
PSyncMultiThread() {}
void Lock()
{
CryWriteLock(&_Semaphore);
m_lock.lock();
}
void Unlock()
{
CryReleaseWriteLock(&_Semaphore);
}
int IsLocked() const volatile
{
return _Semaphore;
m_lock.unlock();
}
private:
volatile int _Semaphore;
AZStd::spin_mutex m_lock;
};
#ifdef _DEBUG
struct PSyncDebug
: public PSyncMultiThread
{
void Lock()
{
assert(!IsLocked());
PSyncMultiThread::Lock();
}
};
#else
typedef PSyncNone PSyncDebug;
#endif
};
#endif // CRYINCLUDE_CRYCOMMON_SYNCHRONIZATION_H
+4 -2
View File
@@ -26,6 +26,8 @@
#include <ISystem.h>
#include <AzCore/std/parallel/spin_mutex.h>
//////////////////////////////////////////////////////////////////////////
// Physics defines.
//////////////////////////////////////////////////////////////////////////
@@ -2834,8 +2836,8 @@ struct IGeometry
virtual int PointInsideStatus(const Vec3& pt) = 0; // for meshes, will create an auxiliary hashgrid for acceleration
// IntersectLocked - the main function for geomtries. pdata1,pdata2,pparams can be 0 - defaults will be assumed.
// returns a pointer to an internal thread-specific contact buffer, locked with the lock argument
virtual int IntersectLocked(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts, WriteLockCond& lock) = 0;
virtual int IntersectLocked(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts, WriteLockCond& lock, int iCaller) = 0;
virtual int IntersectLocked(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts, AZStd::spin_mutex& lock) = 0;
virtual int IntersectLocked(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts, AZStd::spin_mutex& lock, int iCaller) = 0;
// Intersect - same as Intersect, but doesn't lock pcontacts
virtual int Intersect(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts) = 0;
// FindClosestPoint - for non-convex meshes only does local search, doesn't guarantee global minimum
+4 -3
View File
@@ -18,6 +18,7 @@
#include <AzCore/Debug/StackTracer.h>
#include <AzCore/Debug/EventTraceDrillerBus.h>
#include <AzCore/std/parallel/spin_mutex.h>
#define VS_VERSION_INFO 1
#define IDD_CRITICAL_ERROR 101
@@ -152,13 +153,13 @@ void DebugCallStack::SetUserDialogEnable(const bool bUserDialogEnable)
DWORD g_idDebugThreads[10];
const char* g_nameDebugThreads[10];
int g_nDebugThreads = 0;
volatile int g_lockThreadDumpList = 0;
AZStd::spin_mutex g_lockThreadDumpList = 0;
void MarkThisThreadForDebugging(const char* name)
{
EBUS_EVENT(AZ::Debug::EventTraceDrillerSetupBus, SetThreadName, AZStd::this_thread::get_id(), name);
WriteLock lock(g_lockThreadDumpList);
AZStd::lock_guard<AZStd::spin_mutex> lock(g_lockThreadDumpList);
DWORD id = GetCurrentThreadId();
if (g_nDebugThreads == sizeof(g_idDebugThreads) / sizeof(g_idDebugThreads[0]))
{
@@ -178,7 +179,7 @@ void MarkThisThreadForDebugging(const char* name)
void UnmarkThisThreadFromDebugging()
{
WriteLock lock(g_lockThreadDumpList);
AZStd::lock_guard<AZStd::spin_mutex> lock(g_lockThreadDumpList);
DWORD id = GetCurrentThreadId();
for (int i = g_nDebugThreads - 1; i >= 0; i--)
{