From 681c4b915889d63b818acf1aece6bda6129583d7 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Mon, 21 Aug 2023 16:06:00 +0100 Subject: [PATCH] [*] RWLock: revert this branch to checking for 0 and 1 remaining readers [*] Formatting --- Source/Threading/Primitives/AuRWLock.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/Threading/Primitives/AuRWLock.cpp b/Source/Threading/Primitives/AuRWLock.cpp index 12a40d3b..9f15d535 100644 --- a/Source/Threading/Primitives/AuRWLock.cpp +++ b/Source/Threading/Primitives/AuRWLock.cpp @@ -241,7 +241,7 @@ namespace Aurora::Threading::Primitives template bool RWLockImpl::LockWriteNSAbs(AuUInt64 uTimeout) { - if constexpr (!bIsWriteRecursionAllowed) + if constexpr (!bIsWriteRecursionAllowed) { if (TryLockWrite()) { @@ -475,7 +475,13 @@ namespace Aurora::Threading::Primitives uVal = AuAtomicSub(&this->state_, 1); - if (uVal == 0) + bool bAlt {}; + if constexpr (bIsWriteRecursionAllowed) + { + bAlt = uVal == 1; + } + + if (uVal == 0 || bAlt) { bool bElevation {}; @@ -629,6 +635,7 @@ namespace Aurora::Threading::Primitives { return &this->read_; } + template IWaitable *RWLockImpl::AsWritable() {