From 78f8425dc73ac47e9f80753dfaf88e4fbf7c6603 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 4 Oct 2017 16:16:40 +0200 Subject: [PATCH] Announce lock creation. --- client/TracyLock.hpp | 7 +++++++ server/TracyEvent.hpp | 8 ++++++++ server/TracyView.cpp | 24 ++++++++++++++++++++++++ server/TracyView.hpp | 3 +++ 4 files changed, 42 insertions(+) diff --git a/client/TracyLock.hpp b/client/TracyLock.hpp index 6b1215e8..8c1a59f9 100755 --- a/client/TracyLock.hpp +++ b/client/TracyLock.hpp @@ -12,6 +12,13 @@ class Lockable public: Lockable( const SourceLocation* srcloc ) { + Magic magic; + auto& token = s_token; + auto item = s_queue.enqueue_begin( token, magic ); + item->hdr.type = QueueType::LockAnnounce; + item->lockAnnounce.id = (uint64_t)&m_lockable; + item->lockAnnounce.srcloc = (uint64_t)srcloc; + s_queue.enqueue_finish( token, magic ); } Lockable( const Lockable& ) = delete; diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index b2b9e675..4a7e3cb3 100755 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -27,6 +27,14 @@ struct Event enum { EventSize = sizeof( Event ) }; + +struct LockEvent +{ + uint64_t srcloc; +}; + +enum { LockEventSize = sizeof( LockEvent ) }; + } #endif diff --git a/server/TracyView.cpp b/server/TracyView.cpp index a1581a1b..b95d369a 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -373,6 +373,9 @@ void View::Process( const QueueItem& ev ) case QueueType::ZoneName: ProcessZoneName( ev.zoneName ); break; + case QueueType::LockAnnounce: + ProcessLockAnnounce( ev.lockAnnounce ); + break; default: assert( false ); break; @@ -441,6 +444,27 @@ void View::ProcessZoneName( const QueueZoneName& ev ) GetTextData( *zone )->zoneName = ev.name; } +void View::ProcessLockAnnounce( const QueueLockAnnounce& ev ) +{ + CheckSourceLocation( ev.srcloc ); + + auto ptr = m_slab.Alloc(); + ptr->srcloc = ev.srcloc; + + auto it = m_lockMap.find( ev.id ); + if( it == m_lockMap.end() ) + { + m_lockMap.emplace( ev.id, ptr ); + } + else + { + it->second = ptr; + } + + std::lock_guard lock( m_lock ); + m_locks.push_back( ptr ); +} + void View::CheckString( uint64_t ptr ) { if( m_strings.find( ptr ) != m_strings.end() ) return; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index c88890d0..48589507 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -57,6 +57,7 @@ private: void ProcessFrameMark( const QueueFrameMark& ev ); void ProcessZoneText( const QueueZoneText& ev ); void ProcessZoneName( const QueueZoneName& ev ); + void ProcessLockAnnounce( const QueueLockAnnounce& ev ); void CheckString( uint64_t ptr ); void CheckThreadString( uint64_t id ); @@ -116,6 +117,7 @@ private: std::mutex m_lock; Vector m_frames; Vector m_threads; + Vector m_locks; std::unordered_map m_strings; std::unordered_map m_threadNames; std::unordered_set m_customStrings; @@ -132,6 +134,7 @@ private: std::unordered_set m_pendingSourceLocation; std::unordered_map m_pendingCustomStrings; std::unordered_map m_threadMap; + std::unordered_map m_lockMap; Slab m_slab;