[*] SafeDestroy: Use the atomic i noted in the issue

This commit is contained in:
Reece Wilson 2022-09-26 19:01:46 +01:00
parent 86673fbfb6
commit a046eafdd5

View File

@ -49,15 +49,10 @@ namespace AuUtil
public: \
virtual ~type() \
{ \
AuUInt32 uEndState, uCurrentState; \
do \
if (AuAtomicTestAndSet(&this->uCurrentState_, 2)) \
{ \
uCurrentState = this->uCurrentState_; \
uEndState = uCurrentState; \
if (uCurrentState & 2) return; \
uEndState |= 2; \
return; \
} \
while (AuAtomicCompareExchange(&this->uCurrentState_, uEndState, uCurrentState) != uCurrentState); \
\
type :: _TryPreDeconstruct<type>(this); \
\
@ -69,15 +64,10 @@ public: \
\
inline void Destroy() \
{ \
AuUInt32 uEndState, uCurrentState; \
do \
if (AuAtomicTestAndSet(&this->uCurrentState_, 1)) \
{ \
uCurrentState = this->uCurrentState_; \
uEndState = uCurrentState; \
if (uCurrentState & 1) return; \
uEndState |= 1; \
return; \
} \
while (AuAtomicCompareExchange(&this->uCurrentState_, uEndState, uCurrentState) != uCurrentState); \
\
type :: _TryDeconstructPrivate<type>(this); \
} \