From b511719cf46eab8dc0adf473b49e57ce336bf6fe Mon Sep 17 00:00:00 2001 From: NymicRazor Date: Wed, 31 Jul 2024 02:05:46 +0100 Subject: [PATCH] Replace YieldProcessor with sleep for 10 milliseconds due to busy-wait loop --- source/coresystem/cs_param.cpp | 7 +++++-- source/dantelion2/system.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/coresystem/cs_param.cpp b/source/coresystem/cs_param.cpp index 73e1838b..d4a17e32 100644 --- a/source/coresystem/cs_param.cpp +++ b/source/coresystem/cs_param.cpp @@ -3,6 +3,9 @@ #include #include +#include +#include + using namespace from; LIBER_SINGLETON_INSTANCE(CS::SoloParamRepository); @@ -25,11 +28,11 @@ bool CS::SoloParamRepository::wait_for_params(int timeout) { while (!are_params_ready(num_loaded)) { if (GetTickCount64() > wait) return false; - YieldProcessor(); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } else { - while (!are_params_ready(num_loaded)) YieldProcessor(); + while (!are_params_ready(num_loaded)) std::this_thread::sleep_for(std::chrono::milliseconds(10)); } return true; } diff --git a/source/dantelion2/system.cpp b/source/dantelion2/system.cpp index 461c0850..147e898b 100644 --- a/source/dantelion2/system.cpp +++ b/source/dantelion2/system.cpp @@ -3,6 +3,9 @@ #include +#include +#include + using namespace from; bool DLSY::wait_for_system(int timeout) noexcept { @@ -13,11 +16,11 @@ bool DLSY::wait_for_system(int timeout) noexcept { while (*counter == 0) { if (GetTickCount64() > wait) return false; - YieldProcessor(); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } else { - while (*counter == 0) YieldProcessor(); + while (*counter == 0) std::this_thread::sleep_for(std::chrono::milliseconds(10)); } return true; }