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

Add ability to send strings over network.

This commit is contained in:
Bartosz Taudul
2017-09-14 19:24:35 +02:00
parent f3ce055568
commit f61f50385d
3 changed files with 24 additions and 0 deletions
+21
View File
@@ -145,4 +145,25 @@ bool Profiler::SendData( const char* data, size_t len )
return true;
}
bool Profiler::SendString( uint64_t str )
{
auto ptr = (const char*)str;
QueueHeader hdr;
hdr.type = QueueType::StringData;
hdr.id = str;
char buf[TargetFrameSize];
memcpy( buf, &hdr, sizeof( hdr ) );
auto len = strlen( ptr );
assert( len < TargetFrameSize - sizeof( hdr ) - sizeof( uint16_t ) );
assert( len <= std::numeric_limits<uint16_t>::max() );
uint16_t l16 = len;
memcpy( buf + sizeof( hdr ), &l16, sizeof( l16 ) );
memcpy( buf + sizeof( hdr ) + sizeof( l16 ), ptr, l16 );
return SendData( buf, sizeof( hdr ) + sizeof( l16 ) + l16 );
}
}
+1
View File
@@ -36,6 +36,7 @@ private:
void Worker();
bool SendData( const char* data, size_t len );
bool SendString( uint64_t ptr );
static Profiler* Instance();
static moodycamel::ProducerToken& GetToken()