1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Preemptive message text delivery.

This commit is contained in:
Bartosz Taudul
2017-11-11 15:41:21 +01:00
parent 76e11174dc
commit 7f3b8f4647
5 changed files with 21 additions and 44 deletions
+12 -24
View File
@@ -468,7 +468,7 @@ void View::Worker()
if( m_terminate )
{
if( !m_pendingStrings.empty() || !m_pendingThreads.empty() || !m_pendingSourceLocation.empty() ||
!m_pendingCustomStrings.empty() || !m_pendingPlots.empty() || !m_pendingMessages.empty() )
!m_pendingCustomStrings.empty() || !m_pendingPlots.empty() )
{
continue;
}
@@ -496,7 +496,7 @@ close:
void View::DispatchProcess( const QueueItem& ev, char*& ptr )
{
ptr += QueueDataSize[ev.hdr.idx];
if( ev.hdr.type == QueueType::CustomStringData || ev.hdr.type == QueueType::StringData || ev.hdr.type == QueueType::ThreadName || ev.hdr.type == QueueType::PlotName || ev.hdr.type == QueueType::MessageData || ev.hdr.type == QueueType::SourceLocationPayload )
if( ev.hdr.type == QueueType::CustomStringData || ev.hdr.type == QueueType::StringData || ev.hdr.type == QueueType::ThreadName || ev.hdr.type == QueueType::PlotName || ev.hdr.type == QueueType::SourceLocationPayload )
{
uint16_t sz;
memcpy( &sz, ptr, sizeof( sz ) );
@@ -515,9 +515,6 @@ void View::DispatchProcess( const QueueItem& ev, char*& ptr )
case QueueType::PlotName:
HandlePlotName( ev.stringTransfer.ptr, ptr, sz );
break;
case QueueType::MessageData:
AddMessageData( ev.stringTransfer.ptr, ptr, sz );
break;
case QueueType::SourceLocationPayload:
AddSourceLocationPayload( ev.stringTransfer.ptr, ptr, sz );
break;
@@ -669,7 +666,7 @@ void View::ProcessZoneText( const QueueZoneText& ev )
auto it = m_pendingCustomStrings.find( ev.text );
assert( it != m_pendingCustomStrings.end() );
m_lock.lock();
GetTextData( *zone )->userText = it->second;
GetTextData( *zone )->userText = it->second.ptr;
m_lock.unlock();
m_pendingCustomStrings.erase( it );
}
@@ -807,8 +804,14 @@ void View::ProcessPlotData( const QueuePlotData& ev )
void View::ProcessMessage( const QueueMessage& ev )
{
m_pendingMessages.emplace( ev.text, MessagePending { int64_t( ev.time * m_timerMul ), ev.thread } );
ServerQuery( ServerQueryMessage, ev.text );
auto it = m_pendingCustomStrings.find( ev.text );
assert( it != m_pendingCustomStrings.end() );
auto msg = m_slab.Alloc<MessageData>();
msg->time = int64_t( ev.time * m_timerMul );
msg->ref.isidx = true;
msg->ref.stridx = it->second.idx;
InsertMessageData( msg, ev.thread );
m_pendingCustomStrings.erase( it );
}
void View::ProcessMessageLiteral( const QueueMessage& ev )
@@ -883,9 +886,8 @@ void View::AddThreadString( uint64_t id, char* str, size_t sz )
void View::AddCustomString( uint64_t ptr, char* str, size_t sz )
{
const auto sl = StoreString( str, sz );
assert( m_pendingCustomString.find( ptr ) == m_pendingCustomStrings.end() );
m_pendingCustomStrings.emplace( ptr, sl.ptr );
m_pendingCustomStrings.emplace( ptr, StoreString( str, sz ) );
}
View::StringLocation View::StoreString( char* str, size_t sz )
@@ -966,20 +968,6 @@ void View::AddSourceLocationPayload( uint64_t ptr, char* data, size_t sz )
m_pendingSourceLocationPayload.erase( pit );
}
void View::AddMessageData( uint64_t ptr, char* str, size_t sz )
{
const auto sl = StoreString( str, sz );
auto it = m_pendingMessages.find( ptr );
assert( it != m_pendingMessages.end() );
auto msg = m_slab.Alloc<MessageData>();
msg->time = it->second.time;
msg->ref.isidx = true;
msg->ref.stridx = sl.idx;
InsertMessageData( msg, it->second.thread );
m_pendingMessages.erase( it );
}
uint32_t View::ShrinkSourceLocation( uint64_t srcloc )
{
auto it = m_sourceLocationShrink.find( srcloc );