From 412630077d657e5c0a845743db1492484c489734 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Wed, 23 Aug 2023 16:43:43 +0100 Subject: [PATCH] [+] ThreadingConfig::bPreferWaitOnAddressAlwaysSpin --- Include/Aurora/Runtime.hpp | 1 + Source/Threading/AuWakeOnAddress.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Include/Aurora/Runtime.hpp b/Include/Aurora/Runtime.hpp index 92d400c3..72d8677f 100644 --- a/Include/Aurora/Runtime.hpp +++ b/Include/Aurora/Runtime.hpp @@ -362,6 +362,7 @@ namespace Aurora AuUInt64 bPreferLinuxMutexSpinTryLock : 1 { true }; AuUInt64 bPreferLinuxCondMutexSpinTryLock : 1 { true }; AuUInt64 bPreferEmulatedWakeOnAddress : 1 { false }; + AuUInt64 bPreferWaitOnAddressAlwaysSpin : 1 { true }; // ..., if emulated! if double-spinning under higher level locks, disable me. AuUInt64 bPreferRWLockReadLockSpin : 1 { true }; AuUInt64 bUWPNanosecondEmulationCheckFirst: 1 { false }; AuUInt64 uUWPNanosecondEmulationMaxYields : 7 { 12 }; diff --git a/Source/Threading/AuWakeOnAddress.cpp b/Source/Threading/AuWakeOnAddress.cpp index e2328f5b..b0b8a2fa 100644 --- a/Source/Threading/AuWakeOnAddress.cpp +++ b/Source/Threading/AuWakeOnAddress.cpp @@ -826,9 +826,12 @@ namespace Aurora::Threading } else { - if (TryWaitOnAddress(pTargetAddress, pCompareAddress, uWordSize)) + if (gRuntimeConfig.threadingConfig.bPreferWaitOnAddressAlwaysSpin) { - return true; + if (TryWaitOnAddress(pTargetAddress, pCompareAddress, uWordSize)) + { + return true; + } } return WaitOnAddressWide(pTargetAddress, pCompareAddress, uWordSize, qwNanoseconds, {}, false); @@ -927,9 +930,12 @@ namespace Aurora::Threading } else { - if (TryWaitOnAddress(pTargetAddress, pCompareAddress, uWordSize)) + if (gRuntimeConfig.threadingConfig.bPreferWaitOnAddressAlwaysSpin) { - return true; + if (TryWaitOnAddress(pTargetAddress, pCompareAddress, uWordSize)) + { + return true; + } } return WaitOnAddressWide(pTargetAddress, pCompareAddress, uWordSize, {}, qwNanoseconds, false);