[*] Expand WakeOnAddress array and minor lookup optimization

This commit is contained in:
Reece Wilson 2023-12-01 01:35:10 +00:00
parent 43583a1748
commit 0283186046
2 changed files with 6 additions and 4 deletions

View File

@ -419,6 +419,8 @@ namespace Aurora::Threading
this->uAtomic = 0;
}
#define AddressToIndex AuHashCode(pAddressIDC) & (AuArraySize(this->list) - 1)
WaitEntry *ProcessWaitContainer::WaitBufferFrom(const void *pAddress, AuUInt8 uSize)
{
#if defined(FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING)
@ -426,7 +428,7 @@ namespace Aurora::Threading
#else
auto pAddressIDC = pAddress;
#endif
return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].WaitBufferFrom(pAddress, uSize);
return this->list[AddressToIndex].WaitBufferFrom(pAddress, uSize);
}
template <typename T>
@ -437,7 +439,7 @@ namespace Aurora::Threading
#else
auto pAddressIDC = pAddress;
#endif
return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].IterateWake(callback);
return this->list[AddressToIndex].IterateWake(callback);
}
void ProcessWaitContainer::RemoveSelf(const void *pAddress, WaitEntry *pSelf)
@ -447,7 +449,7 @@ namespace Aurora::Threading
#else
auto pAddressIDC = pAddress;
#endif
return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].RemoveSelf(pSelf);
return this->list[AddressToIndex].RemoveSelf(pSelf);
}
bool IsNativeWaitOnSupported()

View File

@ -12,7 +12,7 @@
namespace Aurora::Threading
{
static const auto kDefaultWaitPerProcess = 64;
static const auto kDefaultWaitPerProcess = 128;
struct WaitState;