mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Track connection status.
This commit is contained in:
parent
010b19946f
commit
c973735b49
@ -198,6 +198,9 @@ Profiler::Profiler()
|
||||
, m_lz4Buf( (char*)tracy_malloc( LZ4Size + sizeof( lz4sz_t ) ) )
|
||||
, m_serialQueue( 1024*1024 )
|
||||
, m_serialDequeue( 1024*1024 )
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
, m_isConnected( false )
|
||||
#endif
|
||||
{
|
||||
assert( !s_instance );
|
||||
s_instance = this;
|
||||
@ -290,6 +293,10 @@ void Profiler::Worker()
|
||||
if( m_sock ) break;
|
||||
}
|
||||
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
m_isConnected.store( true, std::memory_order_relaxed );
|
||||
#endif
|
||||
|
||||
m_sock->Send( &welcome, sizeof( welcome ) );
|
||||
LZ4_resetStream( m_stream );
|
||||
|
||||
@ -335,6 +342,10 @@ void Profiler::Worker()
|
||||
}
|
||||
}
|
||||
if( ShouldExit() ) break;
|
||||
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
m_isConnected.store( false, std::memory_order_relaxed );
|
||||
#endif
|
||||
}
|
||||
|
||||
for(;;)
|
||||
|
||||
@ -287,6 +287,13 @@ public:
|
||||
|
||||
static bool ShouldExit();
|
||||
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
tracy_force_inline bool IsConnected()
|
||||
{
|
||||
return m_isConnected.load( std::memory_order_relaxed );
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
enum DequeueStatus { Success, ConnectionLost, QueueEmpty };
|
||||
|
||||
@ -377,6 +384,10 @@ private:
|
||||
|
||||
FastVector<QueueItem> m_serialQueue, m_serialDequeue;
|
||||
NonRecursiveBenaphore m_serialLock;
|
||||
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
std::atomic<bool> m_isConnected;
|
||||
#endif
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user