[*] RWLock: I didn't like what I saw emitted

This commit is contained in:
Reece Wilson 2024-04-30 19:10:03 +01:00
parent 22a4d3383d
commit 410a67d842
2 changed files with 15 additions and 26 deletions

View File

@ -304,6 +304,11 @@ namespace Aurora::Threading::Primitives
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockWriteMaybeSpin()
{
if (this->TryLockWriteNoSpin())
{
return true;
}
if (gUseFutexRWLock)
{
if (DoTryIf([=]()
@ -314,13 +319,6 @@ namespace Aurora::Threading::Primitives
return true;
}
}
else
{
if (this->TryLockWriteNoSpin())
{
return true;
}
}
return false;
}
@ -606,6 +604,11 @@ namespace Aurora::Threading::Primitives
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockRead()
{
if (this->TryLockReadNoSpin<true>())
{
return true;
}
if (ThrdCfg::gPreferRWLockReadLockSpin &&
AuAtomicLoad(&this->dwWritersPending_) == 0)
{
@ -614,10 +617,8 @@ namespace Aurora::Threading::Primitives
return this->TryLockReadNoSpin<true>();
});
}
else
{
return this->TryLockReadNoSpin<true>();
}
return false;
}
template<bool bIsWriteRecursionAllowed>
@ -729,21 +730,9 @@ namespace Aurora::Threading::Primitives
{
if (this->iState_ == 1)
{
if (gUseFutexRWLock)
if (this->UpgradeReadToWriteDoUpgrade())
{
if (this->UpgradeReadToWriteDoUpgrade())
{
return true;
}
}
else
{
RWLockAcquire;
if (this->UpgradeReadToWriteDoUpgrade())
{
return true;
}
return true;
}
}

View File

@ -17,7 +17,7 @@ namespace Aurora::Threading::Primitives
struct RWLockImpl;
template<bool bIsReadView, typename T>
struct RWLockAccessView : IWaitable
struct RWLockAccessView final : IWaitable
{
#if defined(RWLOCK_VIEW_HAS_PARENT)
RWLockAccessView(T &impl) :