mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
UDP broadcast loop.
This commit is contained in:
parent
40e517594b
commit
e609c0fdce
@ -920,6 +920,7 @@ Profiler::Profiler()
|
||||
, m_shutdownManual( false )
|
||||
, m_shutdownFinished( false )
|
||||
, m_sock( nullptr )
|
||||
, m_broadcast( nullptr )
|
||||
, m_noExit( false )
|
||||
, m_zoneId( 1 )
|
||||
, m_stream( LZ4_createStream() )
|
||||
@ -1016,6 +1017,12 @@ Profiler::~Profiler()
|
||||
tracy_free( m_sock );
|
||||
}
|
||||
|
||||
if( m_broadcast )
|
||||
{
|
||||
m_broadcast->~UdpBroadcast();
|
||||
tracy_free( m_broadcast );
|
||||
}
|
||||
|
||||
assert( s_instance );
|
||||
s_instance = nullptr;
|
||||
}
|
||||
@ -1084,6 +1091,15 @@ void Profiler::Worker()
|
||||
}
|
||||
}
|
||||
|
||||
m_broadcast = (UdpBroadcast*)tracy_malloc( sizeof( UdpBroadcast ) );
|
||||
new(m_broadcast) UdpBroadcast();
|
||||
if( !m_broadcast->Open( "255.255.255.255", "8087" ) )
|
||||
{
|
||||
m_broadcast->~UdpBroadcast();
|
||||
tracy_free( m_broadcast );
|
||||
m_broadcast = nullptr;
|
||||
}
|
||||
|
||||
// Connections loop.
|
||||
// Each iteration of the loop handles whole connection. Multiple iterations will only
|
||||
// happen in the on-demand mode or when handshake fails.
|
||||
@ -1104,6 +1120,17 @@ void Profiler::Worker()
|
||||
#ifndef TRACY_ON_DEMAND
|
||||
ProcessSysTime();
|
||||
#endif
|
||||
|
||||
if( m_broadcast )
|
||||
{
|
||||
auto t = std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
||||
if( t - m_lastBroadcast > 5000000000 ) // 5s
|
||||
{
|
||||
m_lastBroadcast = t;
|
||||
m_broadcast->Send( "abc", 3 );
|
||||
auto err = WSAGetLastError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handshake
|
||||
|
@ -47,6 +47,7 @@ namespace tracy
|
||||
class GpuCtx;
|
||||
class Profiler;
|
||||
class Socket;
|
||||
class UdpBroadcast;
|
||||
|
||||
struct GpuCtxWrapper
|
||||
{
|
||||
@ -516,6 +517,7 @@ private:
|
||||
std::atomic<bool> m_shutdownManual;
|
||||
std::atomic<bool> m_shutdownFinished;
|
||||
Socket* m_sock;
|
||||
UdpBroadcast* m_broadcast;
|
||||
bool m_noExit;
|
||||
std::atomic<uint32_t> m_zoneId;
|
||||
|
||||
@ -550,6 +552,8 @@ private:
|
||||
#else
|
||||
void ProcessSysTime() {}
|
||||
#endif
|
||||
|
||||
uint64_t m_lastBroadcast = 0;
|
||||
};
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user