[*] Update a handful of condvar cas's and account for laziness along the way
This commit is contained in:
parent
cd362db7af
commit
76ac770674
@ -129,10 +129,11 @@ namespace Aurora::Threading::Waitables
|
||||
{
|
||||
AuAtomicAdd(&this->uAtomicState, uWaiters);
|
||||
WakeNOnAddress((const void *)&this->uAtomicState, uWaiters);
|
||||
uWaitCount = 1;
|
||||
uWaitCount = uWaiters;
|
||||
}
|
||||
|
||||
while (AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
while (uWaiters &&
|
||||
AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
{
|
||||
uWaiters = this->uAtomicSleeping;
|
||||
|
||||
@ -151,18 +152,20 @@ namespace Aurora::Threading::Waitables
|
||||
uWaiters = this->uAtomicSleeping;
|
||||
if (uWaiters > 0)
|
||||
{
|
||||
AuAtomicAdd(&this->uAtomicState, uThreads);
|
||||
WakeNOnAddress((const void *)&this->uAtomicState, uThreads);
|
||||
uWaitCount = 1;
|
||||
auto uMin = AuMin(uWaiters, uThreads);
|
||||
AuAtomicAdd(&this->uAtomicState, uMin);
|
||||
WakeNOnAddress((const void *)&this->uAtomicState, uMin);
|
||||
uWaitCount = uMin;
|
||||
}
|
||||
|
||||
while (AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
while (uWaiters &&
|
||||
AuAtomicCompareExchange(&this->uAtomicSleeping, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
{
|
||||
uWaiters = this->uAtomicSleeping;
|
||||
|
||||
if (uWaiters == 0)
|
||||
if (uWaiters <= uWaitCount)
|
||||
{
|
||||
return;
|
||||
uWaitCount = uWaiters;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,8 @@ namespace Aurora::Threading::Primitives
|
||||
uWaitCount = 1;
|
||||
}
|
||||
|
||||
while (AuAtomicCompareExchange(&this->uWaiters_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
while (uWaiters &&
|
||||
AuAtomicCompareExchange(&this->uWaiters_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
{
|
||||
uWaiters = this->uWaiters_;
|
||||
|
||||
@ -147,7 +148,8 @@ namespace Aurora::Threading::Primitives
|
||||
uWaitCount = uWaiters;
|
||||
}
|
||||
|
||||
while (AuAtomicCompareExchange(&this->uWaiters_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
while (uWaiters &&
|
||||
AuAtomicCompareExchange(&this->uWaiters_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
{
|
||||
uWaiters = this->uWaiters_;
|
||||
|
||||
|
@ -146,7 +146,8 @@ namespace Aurora::Threading::Primitives
|
||||
uWaitCount = 1;
|
||||
}
|
||||
|
||||
while (AuAtomicCompareExchange(&this->uSleeping_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
while (uWaiters &&
|
||||
AuAtomicCompareExchange(&this->uSleeping_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
{
|
||||
uWaiters = this->uSleeping_;
|
||||
|
||||
@ -170,7 +171,8 @@ namespace Aurora::Threading::Primitives
|
||||
uWaitCount = uWaiters;
|
||||
}
|
||||
|
||||
while (AuAtomicCompareExchange(&this->uSleeping_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
while (uWaiters &&
|
||||
AuAtomicCompareExchange(&this->uSleeping_, uWaiters - uWaitCount, uWaiters) != uWaiters)
|
||||
{
|
||||
uWaiters = this->uSleeping_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user