[*] Improve regressed AuWoA time to wake

This commit is contained in:
Reece Wilson 2024-06-19 22:05:17 +01:00
parent 9805a57647
commit 5b19341186
3 changed files with 21 additions and 18 deletions

View File

@ -67,14 +67,6 @@
#define AUKN_INTERFACE_EXT AUI_INTERFACE_EXT_FWD
#endif
#if defined(AURORA_COMPILER_MSVC) && !defined(MemoryBarrier)
#define AURORA_COMPILER_VOLATILE_BARRIER() __faststorefence()
#elif defined(MemoryBarrier)
#define AURORA_COMPILER_VOLATILE_BARRIER() MemoryBarrier()
#else
#define AURORA_COMPILER_VOLATILE_BARRIER() asm volatile ("" : : : "memory")
#endif
#include "Memory/Memory.hpp"
#include "Utility/PrivData.hpp"

View File

@ -261,7 +261,15 @@ namespace Aurora::Threading
template <EWaitMethod eMethod, bool bFast>
bool WaitBuffer::Compare2(const void *pHot, AuUInt8 uSize, const void *pBuf2, AuUInt64 uMask)
{
return Compare2<eMethod, bFast>((const volatile void *)pHot, uSize, pBuf2, uMask);
}
template <EWaitMethod eMethod, bool bFast>
bool WaitBuffer::Compare2(const volatile void *pHot, AuUInt8 uSize, const void *pBuf2, AuUInt64 uMask)
{
#if !defined(AURORA_COMPILER_CLANG) && !defined(AURORA_COMPILER_MSVC)
AURORA_COMPILER_VOLATILE_BARRIER();
#endif
if constexpr (!bFast)
{
@ -279,7 +287,7 @@ namespace Aurora::Threading
case 8:
return (AuReadU64(pHot, 0) & uMask) == (AuReadU64(pBuf2, 0) & uMask);
default:
return (AuMemcmp(pHot, pBuf2, uSize) == 0);
return (AuMemcmp((const void *)pHot, pBuf2, uSize) == 0);
}
}
@ -296,7 +304,7 @@ namespace Aurora::Threading
case 8:
return !((AuReadU64(pHot, 0) & uMask) == (AuReadU64(pBuf2, 0) & uMask));
default:
return !(AuMemcmp(pHot, pBuf2, uSize) == 0);
return !(AuMemcmp((const void *)pHot, pBuf2, uSize) == 0);
}
}
@ -385,7 +393,7 @@ namespace Aurora::Threading
case 8:
return (AuReadU64(pHot, 0)) == (AuReadU64(pBuf2, 0));
default:
return (AuMemcmp(pHot, pBuf2, uSize) == 0);
return (AuMemcmp((const void *)pHot, pBuf2, uSize) == 0);
}
}
@ -402,7 +410,7 @@ namespace Aurora::Threading
case 8:
return !((AuReadU64(pHot, 0)) == (AuReadU64(pBuf2, 0)));
default:
return !(AuMemcmp(pHot, pBuf2, uSize) == 0);
return !(AuMemcmp((const void *)pHot, pBuf2, uSize) == 0);
}
}
@ -600,14 +608,14 @@ namespace Aurora::Threading
this->waitList.pTail = pEntry->pBefore;
}
if (pEntry->pBefore)
if (auto pBefore = pEntry->pBefore)
{
pEntry->pBefore->pNext = pEntry->pNext;
pBefore->pNext = pEntry->pNext;
}
if (pEntry->pNext)
if (auto pNext = pEntry->pNext)
{
pEntry->pNext->pBefore = pEntry->pBefore;
pNext->pBefore = pEntry->pBefore;
}
if (bAllUnderLock)

View File

@ -42,6 +42,9 @@ namespace Aurora::Threading
// returns false when valid
template <EWaitMethod eMethod, bool bFast = false>
WOAFAST static bool Compare2(const void *pHotAddress, AuUInt8 uSize, const void *pReference, AuUInt64 uMask = 0xFFFFFFFFFFFFFFFF);
template <EWaitMethod eMethod, bool bFast = false>
WOAFAST static bool Compare2(const volatile void *pHotAddress, AuUInt8 uSize, const void *pReference, AuUInt64 uMask = 0xFFFFFFFFFFFFFFFF);
};
struct WaitState
@ -60,8 +63,8 @@ namespace Aurora::Threading
WaitEntry();
~WaitEntry();
WaitEntry *pNext {};
WaitEntry *pBefore {};
WaitEntry * volatile pNext {};
WaitEntry * volatile pBefore {};
// synch
#if defined(WOA_SEMAPHORE_MODE)