[*] dont assume these condvar paths cant underflow

This commit is contained in:
Reece Wilson 2023-08-21 00:25:29 +01:00
parent 3fe2d15a2f
commit a60a1b3088
3 changed files with 8 additions and 4 deletions

View File

@ -37,7 +37,8 @@ namespace Aurora::Threading::Waitables
auto uWaiters = this->uAtomicSleeping;
auto uWaitCount = 1;
while (AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
while (uWaiters &&
AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
{
uWaiters = this->uAtomicSleeping;
@ -74,7 +75,8 @@ namespace Aurora::Threading::Waitables
auto uWaiters = this->uAtomicSleeping;
auto uWaitCount = 1;
while (AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
while (uWaiters &&
AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
{
uWaiters = this->uAtomicSleeping;

View File

@ -65,7 +65,8 @@ namespace Aurora::Threading::Primitives
auto uWaiters = this->uWaiters_;
auto uWaitCount = 1;
while (AuAtomicCompareExchange(&this->uWaiters_, uWaiters - uWaitCount, uWaiters) != uWaiters)
while (uWaiters &&
AuAtomicCompareExchange(&this->uWaiters_, uWaiters - uWaitCount, uWaiters) != uWaiters)
{
uWaiters = this->uWaiters_;

View File

@ -129,7 +129,8 @@ namespace Aurora::Threading::Primitives
auto uWaiters = this->uSleeping_;
auto uWaitCount = 1;
while (AuAtomicCompareExchange(&this->uSleeping_, uWaiters - uWaitCount, uWaiters) != uWaiters)
while (uWaiters &&
AuAtomicCompareExchange(&this->uSleeping_, uWaiters - uWaitCount, uWaiters) != uWaiters)
{
uWaiters = this->uSleeping_;