From 470600fbc2a8cf498df4c4c64cfa1b9747de30e7 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 16 Feb 2019 20:42:50 +0100 Subject: [PATCH] Don't thrash memory bandwith during file load. --- server/TracyFileRead.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/TracyFileRead.hpp b/server/TracyFileRead.hpp index 54614ff9..2b07255d 100644 --- a/server/TracyFileRead.hpp +++ b/server/TracyFileRead.hpp @@ -142,6 +142,7 @@ private: { if( m_exit.load( std::memory_order_relaxed ) == true ) return; if( m_signalSwitch.load( std::memory_order_relaxed ) == true ) break; + std::this_thread::yield(); } m_signalSwitch.store( false, std::memory_order_relaxed ); std::swap( m_buf, m_second ); @@ -165,7 +166,7 @@ private: if( m_offset == BufSize ) { m_signalSwitch.store( true, std::memory_order_relaxed ); - while( m_signalAvailable.load( std::memory_order_acquire ) == false ) {} + while( m_signalAvailable.load( std::memory_order_acquire ) == false ) { std::this_thread::yield(); } m_signalAvailable.store( false, std::memory_order_relaxed ); } @@ -184,7 +185,7 @@ private: if( m_offset == BufSize ) { m_signalSwitch.store( true, std::memory_order_relaxed ); - while( m_signalAvailable.load( std::memory_order_acquire ) == false ) {} + while( m_signalAvailable.load( std::memory_order_acquire ) == false ) { std::this_thread::yield(); } m_signalAvailable.store( false, std::memory_order_relaxed ); }