Don't thrash memory bandwith during file load.

This commit is contained in:
Bartosz Taudul 2019-02-16 20:42:50 +01:00
parent c127f51767
commit 470600fbc2

View File

@ -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 );
}