[*] TryLockRead was unware of RWRenterableLocks specifications

(not an issue for regular blocking lock paths)
This commit is contained in:
Reece Wilson 2023-04-24 19:39:36 +01:00
parent 8dcf857da5
commit 36dee459ca

View File

@ -7,6 +7,7 @@
***/
#include <Source/RuntimeInternal.hpp>
#include "AuRWLock.hpp"
#include "SMTYield.hpp"
namespace Aurora::Threading::Primitives
{
@ -210,14 +211,17 @@ namespace Aurora::Threading::Primitives
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockRead()
{
auto iCurState = this->state_;
if (iCurState == -1)
return DoTryIf([=]()
{
return this->reentrantWriteLockHandle_ == GetThreadCookie();
}
auto iCurState = this->state_;
return AuAtomicCompareExchange(&this->state_, iCurState + 1, iCurState) == iCurState;
if (iCurState < 0)
{
return this->reentrantWriteLockHandle_ == GetThreadCookie();
}
return AuAtomicCompareExchange(&this->state_, iCurState + 1, iCurState) == iCurState;
});
}
template<bool bIsWriteRecursionAllowed>