[redcode/crythread-2nd-pass] replaced remaining CryInterlocked* 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:57:49 -07:00
parent 5a891c8cbd
commit 337ea488b6
3 changed files with 20 additions and 26 deletions
+5 -3
View File
@@ -15,6 +15,8 @@
#pragma once
#include <AzCore/std/parallel/atomic.h>
// Base class for functor storage.
// Not intended for direct usage.
class IFunctorBase
@@ -27,19 +29,19 @@ public:
void AddRef()
{
CryInterlockedIncrement(&m_nReferences);
m_nReferences.fetch_add(1, AZStd::memory_order_acq_rel);
}
void Release()
{
if (CryInterlockedDecrement(&m_nReferences) <= 0)
if (m_nReferences.fetch_sub(1, AZStd::memory_order_acq_rel) == 1)
{
delete this;
}
}
protected:
volatile int m_nReferences;
AZStd::atomic_int m_nReferences;
};
// Base Template for specialization.