From 3b4dc7da3bb5e555a6410cab2ed0fea12e4b10ee Mon Sep 17 00:00:00 2001 From: Joel Linn Date: Fri, 15 Apr 2022 17:52:20 +0200 Subject: [PATCH] [Base] Use disruptorplus spin wait - Attempt to fix deadlocks when using valgrind on CI --- src/xenia/base/testing/threading_test.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xenia/base/testing/threading_test.cc b/src/xenia/base/testing/threading_test.cc index 22db31cbf..f19af2647 100644 --- a/src/xenia/base/testing/threading_test.cc +++ b/src/xenia/base/testing/threading_test.cc @@ -14,6 +14,8 @@ #define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER #include "third_party/catch/include/catch.hpp" +#include "third_party/disruptorplus/include/disruptorplus/spin_wait.hpp" + namespace xe { namespace base { namespace test { @@ -25,12 +27,12 @@ template bool spin_wait_until( const std::chrono::time_point& timeout_time, Predicate stop_waiting) { + disruptorplus::spin_wait spinner; while (!stop_waiting()) { if (std::chrono::steady_clock::now() >= timeout_time) { return false; } - // Needed for valgrind because it basically runs one thread: - MaybeYield(); + spinner.spin_once(); } return true; } @@ -43,9 +45,9 @@ bool spin_wait_for(const std::chrono::duration& rel_time, template void spin_wait(Predicate stop_waiting) { + disruptorplus::spin_wait spinner; while (!stop_waiting()) { - // Needed for valgrind because it basically runs one thread: - MaybeYield(); + spinner.spin_once(); } }