[*] RWLock: I didn't like what I saw emitted
This commit is contained in:
parent
22a4d3383d
commit
410a67d842
@ -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>
|
||||
@ -728,24 +729,12 @@ namespace Aurora::Threading::Primitives
|
||||
bool RWLockImpl<bIsWriteRecursionAllowed>::UpgradeReadToWrite(AuUInt64 uTimeout)
|
||||
{
|
||||
if (this->iState_ == 1)
|
||||
{
|
||||
if (gUseFutexRWLock)
|
||||
{
|
||||
if (this->UpgradeReadToWriteDoUpgrade())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RWLockAcquire;
|
||||
|
||||
if (this->UpgradeReadToWriteDoUpgrade())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto uEndTime = uTimeout ? AuTime::SteadyClockNS() + uTimeout : 0;
|
||||
|
||||
|
@ -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) :
|
||||
|
Loading…
Reference in New Issue
Block a user