diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index b2f4bb15..b9ce909b 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -102,7 +102,8 @@ static Profiler init_order(104) s_profiler; Profiler::Profiler() - : m_mainThread( GetThreadHandle() ) + : m_timeBegin( 0 ) + , m_mainThread( GetThreadHandle() ) , m_epoch( std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ).count() ) , m_shutdown( false ) , m_stream( LZ4_createStream() ) @@ -120,12 +121,13 @@ Profiler::Profiler() CalibrateTimer(); CalibrateDelay(); - uint32_t cpu; - m_timeBegin = GetTime( cpu ); s_thread = (Thread*)tracy_malloc( sizeof( Thread ) ); new(s_thread) Thread( LaunchWorker, this ); SetThreadName( s_thread->Handle(), "Tracy Profiler" ); + + uint32_t cpu; + m_timeBegin.store( GetTime( cpu ), std::memory_order_relaxed ); } Profiler::~Profiler() @@ -155,6 +157,8 @@ void Profiler::Worker() ListenSocket listen; listen.Listen( "8086", 8 ); + while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); + for(;;) { for(;;) diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index b4d4d293..ae8790af 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -177,7 +177,7 @@ private: double m_timerMul; uint64_t m_resolution; uint64_t m_delay; - int64_t m_timeBegin; + std::atomic m_timeBegin; uint64_t m_mainThread; uint64_t m_epoch; std::atomic m_shutdown;