mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Handle incoming strings.
This commit is contained in:
parent
bbbf52eafd
commit
e8989d955c
@ -78,16 +78,19 @@ void View::Worker()
|
|||||||
while( ptr < end )
|
while( ptr < end )
|
||||||
{
|
{
|
||||||
auto ev = (QueueItem*)ptr;
|
auto ev = (QueueItem*)ptr;
|
||||||
Process( *ev );
|
DispatchProcess( *ev, ptr );
|
||||||
ptr += QueueDataSize[ev->hdr.idx];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QueueItem ev;
|
QueueItem ev;
|
||||||
if( !m_sock.Read( &ev.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
|
if( !m_sock.Read( &ev.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
|
||||||
if( !m_sock.Read( ((char*)&ev) + sizeof( QueueHeader ), QueueDataSize[ev.hdr.idx] - sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
|
const auto payload = QueueDataSize[ev.hdr.idx] - sizeof( QueueHeader );
|
||||||
Process( ev );
|
if( payload > 0 )
|
||||||
|
{
|
||||||
|
if( !m_sock.Read( ((char*)&ev) + sizeof( QueueHeader ), payload, &tv, ShouldExit ) ) goto close;
|
||||||
|
}
|
||||||
|
DispatchProcess( ev );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +99,43 @@ close:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::DispatchProcess( const QueueItem& ev )
|
||||||
|
{
|
||||||
|
if( ev.hdr.type == QueueType::StringData )
|
||||||
|
{
|
||||||
|
timeval tv;
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 10000;
|
||||||
|
|
||||||
|
char buf[TargetFrameSize];
|
||||||
|
uint16_t sz;
|
||||||
|
m_sock.Read( &sz, sizeof( sz ), &tv, ShouldExit );
|
||||||
|
m_sock.Read( buf, sz, &tv, ShouldExit );
|
||||||
|
AddString( ev.hdr.id, std::string( buf, buf+sz ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Process( ev );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::DispatchProcess( const QueueItem& ev, const char*& ptr )
|
||||||
|
{
|
||||||
|
ptr += QueueDataSize[ev.hdr.idx];
|
||||||
|
if( ev.hdr.type == QueueType::StringData )
|
||||||
|
{
|
||||||
|
uint16_t sz;
|
||||||
|
memcpy( &sz, ptr, sizeof( sz ) );
|
||||||
|
ptr += sizeof( sz );
|
||||||
|
AddString( ev.hdr.id, std::string( ptr, ptr+sz ) );
|
||||||
|
ptr += sz;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Process( ev );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void View::Process( const QueueItem& ev )
|
void View::Process( const QueueItem& ev )
|
||||||
{
|
{
|
||||||
switch( ev.hdr.type )
|
switch( ev.hdr.type )
|
||||||
|
@ -29,8 +29,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Worker();
|
void Worker();
|
||||||
void Process( const QueueItem& ev );
|
|
||||||
|
|
||||||
|
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 ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev );
|
||||||
void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );
|
void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user