From e285c837a4d2ecbe11fbf3d75c28adf0ff75e269 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 13 Jul 2018 23:55:40 +0200 Subject: [PATCH] Support TRACY_NO_EXIT env variable in addition to define. --- client/TracyProfiler.cpp | 11 ++++++++++- client/TracyProfiler.hpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 1240d218..08167163 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -194,6 +194,7 @@ Profiler::Profiler() , m_epoch( std::chrono::duration_cast( 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; diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index a7332021..ab75b856 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -401,6 +401,7 @@ private: uint64_t m_epoch; std::atomic m_shutdown; Socket* m_sock; + bool m_noExit; LZ4_stream_t* m_stream; char* m_buffer;