mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Rework client handling of server requests.
This commit is contained in:
parent
0f99705243
commit
70ad3407c0
@ -115,10 +115,6 @@ void Profiler::Worker()
|
|||||||
{
|
{
|
||||||
enum { BulkSize = TargetFrameSize / QueueItemSize };
|
enum { BulkSize = TargetFrameSize / QueueItemSize };
|
||||||
|
|
||||||
timeval tv;
|
|
||||||
tv.tv_sec = 0;
|
|
||||||
tv.tv_usec = 10000;
|
|
||||||
|
|
||||||
moodycamel::ConsumerToken token( s_queue );
|
moodycamel::ConsumerToken token( s_queue );
|
||||||
|
|
||||||
ListenSocket listen;
|
ListenSocket listen;
|
||||||
@ -172,9 +168,7 @@ void Profiler::Worker()
|
|||||||
|
|
||||||
while( m_sock->HasData() )
|
while( m_sock->HasData() )
|
||||||
{
|
{
|
||||||
uint64_t ptr;
|
if( !HandleServerQuery() ) break;
|
||||||
if( !m_sock->Read( &ptr, sizeof( ptr ), &tv, ShouldExit ) ) break;
|
|
||||||
SendString( ptr );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,12 +187,12 @@ bool Profiler::SendData( const char* data, size_t len )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Profiler::SendString( uint64_t str )
|
bool Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
|
||||||
{
|
{
|
||||||
auto ptr = (const char*)str;
|
assert( type == QueueType::StringData );
|
||||||
|
|
||||||
QueueHeader hdr;
|
QueueHeader hdr;
|
||||||
hdr.type = QueueType::StringData;
|
hdr.type = type;
|
||||||
hdr.id = str;
|
hdr.id = str;
|
||||||
|
|
||||||
auto buf = m_buffer + m_bufferOffset;
|
auto buf = m_buffer + m_bufferOffset;
|
||||||
@ -217,4 +211,29 @@ bool Profiler::SendString( uint64_t str )
|
|||||||
return SendData( buf, sizeof( hdr ) + sizeof( l16 ) + l16 );
|
return SendData( buf, sizeof( hdr ) + sizeof( l16 ) + l16 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Profiler::HandleServerQuery()
|
||||||
|
{
|
||||||
|
timeval tv;
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 10000;
|
||||||
|
|
||||||
|
uint8_t type;
|
||||||
|
if( !m_sock->Read( &type, sizeof( type ), &tv, ShouldExit ) ) return false;
|
||||||
|
|
||||||
|
uint64_t ptr;
|
||||||
|
if( !m_sock->Read( &ptr, sizeof( ptr ), &tv, ShouldExit ) ) return false;
|
||||||
|
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case ServerQueryString:
|
||||||
|
SendString( ptr, (const char*)ptr, QueueType::StringData );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,9 @@ private:
|
|||||||
void Worker();
|
void Worker();
|
||||||
|
|
||||||
bool SendData( const char* data, size_t len );
|
bool SendData( const char* data, size_t len );
|
||||||
bool SendString( uint64_t ptr );
|
bool SendString( uint64_t ptr, const char* str, QueueType type );
|
||||||
|
|
||||||
|
bool HandleServerQuery();
|
||||||
|
|
||||||
int64_t m_timeBegin;
|
int64_t m_timeBegin;
|
||||||
std::thread m_thread;
|
std::thread m_thread;
|
||||||
|
@ -290,6 +290,9 @@ void View::CheckString( uint64_t ptr )
|
|||||||
if( m_pendingStrings.find( ptr ) != m_pendingStrings.end() ) return;
|
if( m_pendingStrings.find( ptr ) != m_pendingStrings.end() ) return;
|
||||||
|
|
||||||
m_pendingStrings.emplace( ptr );
|
m_pendingStrings.emplace( ptr );
|
||||||
|
|
||||||
|
uint8_t type = ServerQueryString;
|
||||||
|
m_sock.Send( &type, sizeof( type ) );
|
||||||
m_sock.Send( &ptr, sizeof( ptr ) );
|
m_sock.Send( &ptr, sizeof( ptr ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user