Support TRACY_NO_EXIT env variable in addition to define.

This commit is contained in:
Bartosz Taudul 2018-07-13 23:55:40 +02:00
parent c3ba0ef4eb
commit e285c837a4
2 changed files with 11 additions and 1 deletions

View File

@ -194,6 +194,7 @@ Profiler::Profiler()
, m_epoch( std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch() ).count() )
, m_shutdown( false )
, m_sock( nullptr )
, m_noExit( false )
, m_stream( LZ4_createStream() )
, m_buffer( (char*)tracy_malloc( TargetFrameSize*3 ) )
, m_bufferOffset( 0 )
@ -220,6 +221,14 @@ Profiler::Profiler()
CalibrateTimer();
CalibrateDelay();
#ifndef TRACY_NO_EXIT
const char* noExitEnv = getenv( "TRACY_NO_EXIT" );
if( noExitEnv && noExitEnv[0] == '1' )
{
m_noExit = true;
}
#endif
s_thread = (Thread*)tracy_malloc( sizeof( Thread ) );
new(s_thread) Thread( LaunchWorker, this );
SetThreadName( s_thread->Handle(), "Tracy Profiler" );
@ -293,7 +302,7 @@ void Profiler::Worker()
for(;;)
{
#ifndef TRACY_NO_EXIT
if( ShouldExit() ) return;
if( !m_noExit && ShouldExit() ) return;
#endif
m_sock = listen.Accept();
if( m_sock ) break;

View File

@ -401,6 +401,7 @@ private:
uint64_t m_epoch;
std::atomic<bool> m_shutdown;
Socket* m_sock;
bool m_noExit;
LZ4_stream_t* m_stream;
char* m_buffer;