diff --git a/Source/Threading/Primitives/SMTYield.cpp b/Source/Threading/Primitives/SMTYield.cpp index 20e79575..79422850 100644 --- a/Source/Threading/Primitives/SMTYield.cpp +++ b/Source/Threading/Primitives/SMTYield.cpp @@ -81,6 +81,8 @@ namespace Aurora::Threading::Primitives gUseFutexRWLock = ThrdCfg::gPreferFutexRWLock && IsWaitOnRecommended(); + gSpinAdaptiveThreadCount = uCores; + if (uCores == 1) { gSpinAdaptiveThreshold = 0; diff --git a/Source/Threading/Primitives/SMTYield.hpp b/Source/Threading/Primitives/SMTYield.hpp index 412c3016..19b990b0 100644 --- a/Source/Threading/Primitives/SMTYield.hpp +++ b/Source/Threading/Primitives/SMTYield.hpp @@ -54,6 +54,7 @@ namespace Aurora::Threading::Primitives inline AuUInt32 gSpinAdaptiveThreshold {}; inline AuUInt32 gSpinAdaptiveCurrentCount {}; + inline AuUInt32 gSpinAdaptiveThreadCount {}; inline AuUInt32 gUseFutexRWLock {}; @@ -144,7 +145,7 @@ namespace Aurora::Threading::Primitives AuAtomicSub(&gSpinAdaptiveCurrentCount, 1u); } - else + else if (uNow <= gSpinAdaptiveThreadCount) { auto uCount = (spin) / 3; #if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86)