diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 43aaccb9..9080c1d5 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1202,6 +1202,7 @@ finishLoading: s_loadProgress.total.store( 0, std::memory_order_relaxed ); m_loadTime = std::chrono::duration_cast( std::chrono::high_resolution_clock::now() - loadStart ).count(); + m_backgroundDone.store( false, std::memory_order_relaxed ); #ifndef TRACY_NO_STATISTICS m_threadBackground = std::thread( [this, reconstructMemAllocPlot] { std::function&, uint16_t)> ProcessTimeline; @@ -1241,11 +1242,12 @@ finishLoading: m_data.sourceLocationZonesReady = true; } if( reconstructMemAllocPlot ) ReconstructMemAllocPlot(); + m_backgroundDone.store( true, std::memory_order_relaxed ); } ); #else if( reconstructMemAllocPlot ) { - m_threadBackground = std::thread( [this] { ReconstructMemAllocPlot(); } ); + m_threadBackground = std::thread( [this] { ReconstructMemAllocPlot(); m_backgroundDone.store( true, std::memory_order_relaxed ); } ); } #endif } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 53004f8e..f2267678 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -323,6 +323,7 @@ public: bool HasData() const { return m_hasData.load( std::memory_order_acquire ); } bool IsConnected() const { return m_connected.load( std::memory_order_relaxed ); } bool IsDataStatic() const { return !m_thread.joinable(); } + bool IsBackgroundDone() const { return m_backgroundDone.load( std::memory_order_relaxed ); } void Shutdown() { m_shutdown.store( true, std::memory_order_relaxed ); } void Disconnect() { Shutdown(); } // TODO: Needs proper implementation. @@ -464,6 +465,7 @@ private: std::atomic m_hasData; std::atomic m_shutdown { false }; + std::atomic m_backgroundDone { true }; std::thread m_threadBackground; int64_t m_delay;