From a203eb5aef532ef8b1131c87b336bf7eec1f6aea Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 14 Nov 2021 18:50:59 +0100 Subject: [PATCH] Adapt to SPSCQueue interface. --- client/TracyProfiler.cpp | 27 +++++++++++++++++++-------- client/TracyProfiler.hpp | 4 ++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 519f511d..3abb5363 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1901,8 +1901,13 @@ void Profiler::Worker() } #ifdef TRACY_HAS_CALLSTACK - SymbolQueueItem si; - while( m_symbolQueue.try_dequeue( si ) ) HandleSymbolQueueItem( si ); + for(;;) + { + auto si = m_symbolQueue.front(); + if( !si ) break; + HandleSymbolQueueItem( *si ); + m_symbolQueue.pop(); + } #endif } @@ -1928,8 +1933,13 @@ void Profiler::Worker() } } #ifdef TRACY_HAS_CALLSTACK - SymbolQueueItem si; - while( m_symbolQueue.try_dequeue( si ) ) HandleSymbolQueueItem( si ); + for(;;) + { + auto si = m_symbolQueue.front(); + if( !si ) break; + HandleSymbolQueueItem( *si ); + m_symbolQueue.pop(); + } #endif while( Dequeue( token ) == DequeueStatus::DataDequeued ) {} while( DequeueSerial() == DequeueStatus::DataDequeued ) {} @@ -3171,19 +3181,20 @@ void Profiler::SymbolWorker() for(;;) { const auto shouldExit = ShouldExit(); - SymbolQueueItem si; #ifdef TRACY_ON_DEMAND if( !IsConnected() ) { if( shouldExit ) return; - while( m_symbolQueue.pop() ) {} + while( m_symbolQueue.front() ) m_symbolQueue.pop(); std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); continue; } #endif - if( m_symbolQueue.try_dequeue( si ) ) + auto si = m_symbolQueue.front(); + if( si ) { - HandleSymbolQueueItem( si ); + HandleSymbolQueueItem( *si ); + m_symbolQueue.pop(); } else { diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 42c7038d..7c2c8170 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -8,7 +8,7 @@ #include #include "tracy_concurrentqueue.h" -#include "tracy_readerwriterqueue.h" +#include "tracy_SPSCQueue.h" #include "TracyCallstack.hpp" #include "TracySysTime.hpp" #include "TracyFastVector.hpp" @@ -864,7 +864,7 @@ private: TracyMutex m_fiLock; #endif - ReaderWriterQueue m_symbolQueue; + SPSCQueue m_symbolQueue; std::atomic m_frameCount; std::atomic m_isConnected;