Track server connection status.

This commit is contained in:
Bartosz Taudul 2017-09-18 00:31:09 +02:00
parent 8f29976237
commit 76aad0d2a4
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,7 @@ static View* s_instance = nullptr;
View::View( const char* addr ) View::View( const char* addr )
: m_addr( addr ) : m_addr( addr )
, m_shutdown( false ) , m_shutdown( false )
, m_connected( false )
, m_mbps( 64 ) , m_mbps( 64 )
, m_stream( LZ4_createStreamDecode() ) , m_stream( LZ4_createStreamDecode() )
, m_buffer( new char[TargetFrameSize*3] ) , m_buffer( new char[TargetFrameSize*3] )
@ -74,6 +75,8 @@ void View::Worker()
m_frames.push_back( timeStart ); m_frames.push_back( timeStart );
LZ4_setStreamDecode( m_stream, nullptr, 0 ); LZ4_setStreamDecode( m_stream, nullptr, 0 );
m_connected.store( true, std::memory_order_relaxed );
t0 = std::chrono::high_resolution_clock::now(); t0 = std::chrono::high_resolution_clock::now();
for(;;) for(;;)
@ -131,6 +134,7 @@ void View::Worker()
close: close:
m_sock.Close(); m_sock.Close();
m_connected.store( false, std::memory_order_relaxed );
} }
} }

View File

@ -55,6 +55,7 @@ private:
Socket m_sock; Socket m_sock;
std::thread m_thread; std::thread m_thread;
std::atomic<bool> m_shutdown; std::atomic<bool> m_shutdown;
std::atomic<bool> m_connected;
// this block must be locked // this block must be locked
std::mutex m_lock; std::mutex m_lock;