[*] RWLock: improper upgrade handshake

The switch over to two condvars still doesnt seem right
This commit is contained in:
Reece Wilson 2023-08-21 16:19:14 +01:00
parent 681c4b9158
commit e1f384de2e

View File

@ -288,12 +288,22 @@ namespace Aurora::Threading::Primitives
return false;
}
}
#if defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
if (!this->GetConditionWriter().WaitForSignalNS(iSecondTimeout))
bool bStatus = this->GetConditionWriter().WaitForSignalNS(iSecondTimeout);
#else
if (!this->GetConditionWriter().WaitForSignalNsEx(AuUnsafeRaiiToShared(&this->mutex_), iSecondTimeout))
bool bStatus = this->GetConditionWriter().WaitForSignalNsEx(AuUnsafeRaiiToShared(&this->mutex_), iSecondTimeout);
#endif
if constexpr (bIsWriteRecursionAllowed)
{
if (this->state_ == 1)
{
this->GetConditionWriter().Broadcast();
}
}
if (!bStatus)
{
AuAtomicSub(&this->writersPending_, 1);
return false;
@ -308,6 +318,7 @@ namespace Aurora::Threading::Primitives
}
else
{
// TBD:
this->GetConditionWriter().Broadcast();
this->GetCondition().Broadcast();
}
@ -370,10 +381,20 @@ namespace Aurora::Threading::Primitives
}
#if defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
if (!this->GetConditionWriter().WaitForSignalNS(uSecondTimeout))
bool bStatus = this->GetConditionWriter().WaitForSignalNS(uSecondTimeout);
#else
if (!this->GetConditionWriter().WaitForSignalNsEx(AuUnsafeRaiiToShared(&this->mutex_), uSecondTimeout))
bool bStatus = this->GetConditionWriter().WaitForSignalNsEx(AuUnsafeRaiiToShared(&this->mutex_), uSecondTimeout);
#endif
if constexpr (bIsWriteRecursionAllowed)
{
if (this->state_ == 1)
{
this->GetConditionWriter().Broadcast();
}
}
if (!bStatus)
{
AuAtomicSub(&this->writersPending_, 1);
return false;
@ -388,6 +409,7 @@ namespace Aurora::Threading::Primitives
}
else
{
// TBD:
this->GetConditionWriter().Broadcast();
this->GetCondition().Broadcast();
}