Don't show profiler window before connection is established.

This commit is contained in:
Bartosz Taudul 2017-09-20 20:38:12 +02:00
parent 2761c719de
commit fc01be2138
2 changed files with 12 additions and 1 deletions

View File

@ -24,6 +24,7 @@ View::View( const char* addr )
: m_addr( addr )
, m_shutdown( false )
, m_connected( false )
, m_hasData( false )
, m_mbps( 64 )
, m_stream( LZ4_createStreamDecode() )
, m_buffer( new char[TargetFrameSize*3] )
@ -80,8 +81,9 @@ void View::Worker()
if( !m_sock.Read( &lz4, sizeof( lz4 ), &tv, ShouldExit ) ) goto close;
m_frames.push_back( timeStart );
LZ4_setStreamDecode( m_stream, nullptr, 0 );
m_hasData.store( true, std::memory_order_release );
LZ4_setStreamDecode( m_stream, nullptr, 0 );
m_connected.store( true, std::memory_order_relaxed );
t0 = std::chrono::high_resolution_clock::now();
@ -366,6 +368,14 @@ void View::Draw()
void View::DrawImpl()
{
if( !m_hasData.load( std::memory_order_acquire ) )
{
ImGui::Begin( m_addr.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders );
ImGui::Text( "Waiting for connection..." );
ImGui::End();
return;
}
// Connection window
ImGui::Begin( m_addr.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders );
{

View File

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