[+] ThreadingConfig::bPreferRWLockReadLockSpin

This commit is contained in:
Reece Wilson 2023-08-21 16:25:16 +01:00
parent e1f384de2e
commit f847ab049a
2 changed files with 16 additions and 3 deletions

View File

@ -361,6 +361,7 @@ namespace Aurora
AuUInt64 bPreferLinuxMutexSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxCondMutexSpinTryLock : 1 { true };
AuUInt64 bPreferEmulatedWakeOnAddress : 1 { false };
AuUInt64 bPreferRWLockReadLockSpin : 1 { true };
};
struct DummyConfig

View File

@ -141,7 +141,7 @@ namespace Aurora::Threading::Primitives
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::LockReadNSAbs(AuUInt64 uTimeout)
{
if (this->TryLockReadNoSpin())
if (this->TryLockRead())
{
return true;
}
@ -197,6 +197,11 @@ namespace Aurora::Threading::Primitives
AuInt64 uEndTime = uTimeout ? AuTime::SteadyClockNS() + uTimeout : 0;
if (this->TryLockRead())
{
return true;
}
AuInt32 iCurState {};
do
{
@ -421,10 +426,17 @@ namespace Aurora::Threading::Primitives
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockRead()
{
return DoTryIf([=]()
if (gRuntimeConfig.threadingConfig.bPreferRWLockReadLockSpin)
{
return DoTryIf([=]()
{
return TryLockReadNoSpin();
});
}
else
{
return TryLockReadNoSpin();
});
}
}
template<bool bIsWriteRecursionAllowed>