From 0431c035568ad3f97a05406af9d93f5838c5b2d9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 12 Aug 2019 13:27:15 +0200 Subject: [PATCH] Add serial queue interface. --- client/TracyProfiler.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index e9334165..045677b2 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -152,6 +152,20 @@ public: return m_zoneId.fetch_add( 1, std::memory_order_relaxed ); } + static tracy_force_inline QueueItem* QueueSerial() + { + auto& p = GetProfiler(); + p.m_serialLock.lock(); + return p.m_serialQueue.prepare_next(); + } + + static tracy_force_inline void QueueSerialFinish() + { + auto& p = GetProfiler(); + p.m_serialQueue.commit_next(); + p.m_serialLock.unlock(); + } + static tracy_force_inline void SendFrameMark( const char* name ) { if( !name ) GetProfiler().m_frameCount.fetch_add( 1, std::memory_order_relaxed ); @@ -174,13 +188,11 @@ public: #ifdef TRACY_ON_DEMAND if( !GetProfiler().IsConnected() ) return; #endif - GetProfiler().m_serialLock.lock(); - auto item = GetProfiler().m_serialQueue.prepare_next(); + auto item = QueueSerial(); MemWrite( &item->hdr.type, type ); MemWrite( &item->frameMark.time, GetTime() ); MemWrite( &item->frameMark.name, uint64_t( name ) ); - GetProfiler().m_serialQueue.commit_next(); - GetProfiler().m_serialLock.unlock(); + QueueSerialFinish(); } static tracy_force_inline void SendFrameImage( const void* image, uint16_t w, uint16_t h, uint8_t offset, bool flip )