[*] Minor RW lock tweaks

This commit is contained in:
Reece Wilson 2023-08-30 14:57:13 +01:00
parent af8737e9d2
commit cf118d0b4b

View File

@ -474,7 +474,8 @@ namespace Aurora::Threading::Primitives
if constexpr (bIsWriteRecursionAllowed) if constexpr (bIsWriteRecursionAllowed)
{ {
if (this->state_ == 1) if (AuAtomicLoad(&this->state_) == 1 &&
AuAtomicLoad(&this->writersPending_))
{ {
this->SignalManyWriter(); this->SignalManyWriter();
} }
@ -652,7 +653,7 @@ namespace Aurora::Threading::Primitives
if (!gUseFutexRWLock) if (!gUseFutexRWLock)
{ {
AU_LOCK_GUARD(this->mutex_); /* actually locking this->state_, out of branch. required for the mutually exclusive correctness of the condition. this is a fence. */ AU_LOCK_GUARD(this->mutex_); /* actually locking this->state_, out of branch. required for the mutually exclusive correctness of the condition. this is a fence. */
bElevation = this->writersPending_ > 0; bElevation = AuAtomicLoad(&this->writersPending_) > 0;
} }
else else
{ {
@ -663,10 +664,6 @@ namespace Aurora::Threading::Primitives
{ {
this->SignalOneWriter(); this->SignalOneWriter();
} }
else
{
this->SignalManyReader();
}
} }
} }
@ -683,7 +680,7 @@ namespace Aurora::Threading::Primitives
{ {
AU_LOCK_GUARD(this->mutex_); AU_LOCK_GUARD(this->mutex_);
AuAtomicStore(&this->state_, 0); AuAtomicStore(&this->state_, 0);
bElevationPending = this->writersPending_ > 0; bElevationPending = AuAtomicLoad(&this->writersPending_) > 0;
} }
else else
{ {
@ -725,11 +722,11 @@ namespace Aurora::Threading::Primitives
if (!gUseFutexRWLock) if (!gUseFutexRWLock)
{ {
AU_LOCK_GUARD(this->mutex_); AU_LOCK_GUARD(this->mutex_);
bElevationPending = this->writersPending_ > 0; bElevationPending = AuAtomicLoad(&this->writersPending_) > 0;
} }
else else
{ {
bElevationPending = this->writersPending_ > 0; bElevationPending = AuAtomicLoad(&this->writersPending_) > 0;
} }
if (bElevationPending) if (bElevationPending)