mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-01 16:08:30 +00:00
Merge pull request #1461 from ofoure/master
Added Profiler::GetPort() and TracyPort macro
This commit is contained in:
@@ -804,6 +804,8 @@ Suppose for some reason you want to use another port\footnote{For example, other
|
||||
|
||||
If a custom port is not specified and the default listening port is already occupied, the profiler will automatically try to listen on a number of other ports.
|
||||
|
||||
Since the port in use may differ from the default one, the client application may query the actual data connection port using the \texttt{TracyPort} macro. It returns the port number once the listening socket has been bound, or zero otherwise.
|
||||
|
||||
\begin{bclogo}[
|
||||
noborder=true,
|
||||
couleur=black!5,
|
||||
|
||||
@@ -1552,6 +1552,7 @@ Profiler::Profiler()
|
||||
, m_broadcast( nullptr )
|
||||
, m_noExit( false )
|
||||
, m_userPort( 0 )
|
||||
, m_dataPort( 0 )
|
||||
, m_zoneId( 1 )
|
||||
, m_sectionId( 1 )
|
||||
, m_samplingPeriod( 0 )
|
||||
@@ -1955,6 +1956,7 @@ void Profiler::Worker()
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
||||
}
|
||||
}
|
||||
m_dataPort.store( dataPort, std::memory_order_release );
|
||||
|
||||
#ifndef TRACY_NO_BROADCAST
|
||||
m_broadcast = (UdpBroadcast*)tracy_malloc( sizeof( UdpBroadcast ) );
|
||||
|
||||
@@ -914,6 +914,12 @@ public:
|
||||
return m_isConnected.load( std::memory_order_acquire );
|
||||
}
|
||||
|
||||
// Returns 0 until the listen socket is bound
|
||||
tracy_force_inline uint32_t GetPort() const
|
||||
{
|
||||
return m_dataPort.load( std::memory_order_acquire );
|
||||
}
|
||||
|
||||
tracy_force_inline void SetProgramName( const char* name )
|
||||
{
|
||||
m_programNameLock.lock();
|
||||
@@ -1175,6 +1181,7 @@ private:
|
||||
UdpBroadcast* m_broadcast;
|
||||
bool m_noExit;
|
||||
uint32_t m_userPort;
|
||||
std::atomic<uint32_t> m_dataPort;
|
||||
std::atomic<uint32_t> m_zoneId;
|
||||
std::atomic<uint32_t> m_sectionId;
|
||||
int64_t m_samplingPeriod;
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
#define TracyParameterRegister(x,y)
|
||||
#define TracyParameterSetup(x,y,z,w)
|
||||
#define TracyIsConnected false
|
||||
#define TracyPort 0
|
||||
#define TracyIsStarted false
|
||||
#define TracySetProgramName(x)
|
||||
|
||||
@@ -258,6 +259,7 @@
|
||||
#define TracyParameterRegister( cb, data ) tracy::Profiler::ParameterRegister( cb, data )
|
||||
#define TracyParameterSetup( idx, name, type, val ) tracy::Profiler::ParameterSetup( idx, name, type, val )
|
||||
#define TracyIsConnected tracy::GetProfiler().IsConnected()
|
||||
#define TracyPort tracy::GetProfiler().GetPort()
|
||||
#define TracySetProgramName( name ) tracy::GetProfiler().SetProgramName( name )
|
||||
|
||||
#define TracySectionEnter( fmt, ... ) tracy::Profiler::SectionEnter( 0, fmt, ##__VA_ARGS__ )
|
||||
|
||||
Reference in New Issue
Block a user