mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Preemptive sending of custom strings.
This commit is contained in:
parent
c2797a4cc7
commit
76e11174dc
@ -263,7 +263,20 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
{
|
||||
for( size_t i=0; i<sz; i++ )
|
||||
{
|
||||
if( !AppendData( m_itemBuf+i, QueueDataSize[m_itemBuf[i].hdr.idx] ) ) return ConnectionLost;
|
||||
const auto item = m_itemBuf + i;
|
||||
switch( item->hdr.type )
|
||||
{
|
||||
case QueueType::ZoneText:
|
||||
{
|
||||
const auto ptr = item->zoneText.text;
|
||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( !AppendData( item, QueueDataSize[m_itemBuf[i].hdr.idx] ) ) return ConnectionLost;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -394,10 +407,6 @@ bool Profiler::HandleServerQuery()
|
||||
SendString( ptr, GetThreadName( ptr ), QueueType::ThreadName );
|
||||
}
|
||||
break;
|
||||
case ServerQueryCustomString:
|
||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
case ServerQuerySourceLocation:
|
||||
SendSourceLocation( ptr );
|
||||
break;
|
||||
|
@ -21,7 +21,6 @@ enum ServerQuery : uint8_t
|
||||
ServerQueryTerminate,
|
||||
ServerQueryString,
|
||||
ServerQueryThreadString,
|
||||
ServerQueryCustomString,
|
||||
ServerQuerySourceLocation,
|
||||
ServerQuerySourceLocationPayload,
|
||||
ServerQueryPlotName,
|
||||
|
@ -666,7 +666,12 @@ void View::ProcessZoneText( const QueueZoneText& ev )
|
||||
auto& stack = m_zoneStack[ev.thread];
|
||||
assert( !stack.empty() );
|
||||
auto zone = stack.back();
|
||||
CheckCustomString( ev.text, zone );
|
||||
auto it = m_pendingCustomStrings.find( ev.text );
|
||||
assert( it != m_pendingCustomStrings.end() );
|
||||
m_lock.lock();
|
||||
GetTextData( *zone )->userText = it->second;
|
||||
m_lock.unlock();
|
||||
m_pendingCustomStrings.erase( it );
|
||||
}
|
||||
|
||||
void View::ProcessZoneName( const QueueZoneName& ev )
|
||||
@ -836,14 +841,6 @@ void View::CheckThreadString( uint64_t id )
|
||||
ServerQuery( ServerQueryThreadString, id );
|
||||
}
|
||||
|
||||
void View::CheckCustomString( uint64_t ptr, ZoneEvent* dst )
|
||||
{
|
||||
assert( m_pendingCustomStrings.find( ptr ) == m_pendingCustomStrings.end() );
|
||||
m_pendingCustomStrings.emplace( ptr, dst );
|
||||
|
||||
ServerQuery( ServerQueryCustomString, ptr );
|
||||
}
|
||||
|
||||
void View::CheckSourceLocation( uint64_t ptr )
|
||||
{
|
||||
if( m_sourceLocation.find( ptr ) != m_sourceLocation.end() ) return;
|
||||
@ -886,13 +883,9 @@ void View::AddThreadString( uint64_t id, char* str, size_t sz )
|
||||
|
||||
void View::AddCustomString( uint64_t ptr, char* str, size_t sz )
|
||||
{
|
||||
auto pit = m_pendingCustomStrings.find( ptr );
|
||||
assert( pit != m_pendingCustomStrings.end() );
|
||||
const auto sl = StoreString( str, sz );
|
||||
m_lock.lock();
|
||||
GetTextData( *pit->second )->userText = sl.ptr;
|
||||
m_lock.unlock();
|
||||
m_pendingCustomStrings.erase( pit );
|
||||
assert( m_pendingCustomString.find( ptr ) == m_pendingCustomStrings.end() );
|
||||
m_pendingCustomStrings.emplace( ptr, sl.ptr );
|
||||
}
|
||||
|
||||
View::StringLocation View::StoreString( char* str, size_t sz )
|
||||
|
@ -148,7 +148,6 @@ private:
|
||||
|
||||
void CheckString( uint64_t ptr );
|
||||
void CheckThreadString( uint64_t id );
|
||||
void CheckCustomString( uint64_t ptr, ZoneEvent* dst );
|
||||
void CheckSourceLocation( uint64_t ptr );
|
||||
void CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst );
|
||||
|
||||
@ -260,7 +259,7 @@ private:
|
||||
std::unordered_set<uint64_t> m_pendingStrings;
|
||||
std::unordered_set<uint64_t> m_pendingThreads;
|
||||
std::unordered_set<uint64_t> m_pendingSourceLocation;
|
||||
std::unordered_map<uint64_t, ZoneEvent*> m_pendingCustomStrings;
|
||||
std::unordered_map<uint64_t, const char*> m_pendingCustomStrings;
|
||||
std::unordered_map<uint64_t, uint32_t> m_threadMap;
|
||||
std::unordered_map<uint64_t, uint32_t> m_plotMap;
|
||||
std::unordered_map<const char*, uint32_t, charutil::Hasher, charutil::Comparator> m_plotRev;
|
||||
|
Loading…
Reference in New Issue
Block a user