[*] ...same applies to these

This commit is contained in:
Reece Wilson 2023-08-26 18:46:00 +01:00
parent 87c3ac790d
commit 7680a86d5a
2 changed files with 12 additions and 11 deletions

View File

@ -118,14 +118,15 @@ namespace Aurora::Threading::Primitives
AuUInt32 uWaiters {}; AuUInt32 uWaiters {};
uWaiters = AuAtomicLoad(&this->uWaiters_); uWaiters = AuAtomicLoad(&this->uWaiters_);
if (uWaiters > 0) if (uWaiters == 0)
{ {
this->s_.Unlock(); return;
uWaitCount = 1;
} }
this->s_.Unlock();
while (uWaiters && while (uWaiters &&
AuAtomicCompareExchange(&this->uWaiters_, uWaiters - uWaitCount, uWaiters) != uWaiters) AuAtomicCompareExchange(&this->uWaiters_, uWaiters - 1u, uWaiters) != uWaiters)
{ {
uWaiters = this->uWaiters_; uWaiters = this->uWaiters_;

View File

@ -135,19 +135,19 @@ namespace Aurora::Threading::Primitives
void ConditionVariableLinux::Signal() void ConditionVariableLinux::Signal()
{ {
AuUInt32 uWaitCount {};
AuUInt32 uWaiters {}; AuUInt32 uWaiters {};
uWaiters = AuAtomicLoad(&this->uSleeping_); uWaiters = AuAtomicLoad(&this->uSleeping_);
if (uWaiters > 0) if (uWaiters == 0)
{ {
AuAtomicAdd(&this->uState_, 1u); return;
futex_wake(&this->uState_, 1u);
uWaitCount = 1;
} }
AuAtomicAdd(&this->uState_, 1u);
futex_wake(&this->uState_, 1u);
while (uWaiters && while (uWaiters &&
AuAtomicCompareExchange(&this->uSleeping_, uWaiters - uWaitCount, uWaiters) != uWaiters) AuAtomicCompareExchange(&this->uSleeping_, uWaiters - 1u, uWaiters) != uWaiters)
{ {
uWaiters = this->uSleeping_; uWaiters = this->uSleeping_;