#ifndef __TRACYVIEW_HPP__ #define __TRACYVIEW_HPP__ #include #include #include #include #include #include #include #include "../common/TracySocket.hpp" #include "../common/TracyQueue.hpp" #include "TracyEvent.hpp" #include "TracySlab.hpp" #include "TracyVector.hpp" namespace tracy { struct QueueItem; class View { public: View() : View( "127.0.0.1" ) {} View( const char* addr ); ~View(); static bool ShouldExit(); static void Draw(); private: void Worker(); void DispatchProcess( const QueueItem& ev ); void DispatchProcess( const QueueItem& ev, const char*& ptr ); void Process( const QueueItem& ev ); void ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev ); void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev ); void ProcessFrameMark( uint64_t id ); void CheckString( uint64_t ptr ); void AddString( uint64_t ptr, std::string&& str ); void NewZone( Event* zone ); void UpdateZone( Event* zone ); void DrawImpl(); std::string m_addr; Socket m_sock; std::thread m_thread; std::atomic m_shutdown; // this block must be locked std::mutex m_lock; Vector m_timeline; Vector m_frames; std::unordered_map m_strings; std::mutex m_mbpslock; std::vector m_mbps; // not used for vis - no need to lock std::unordered_map m_pendingEndZone; std::unordered_map m_openZones; std::unordered_set m_pendingStrings; Slab m_slab; }; } #endif