mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Add ability to send strings over network.
This commit is contained in:
parent
f3ce055568
commit
f61f50385d
@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -10,6 +10,7 @@ enum class QueueType : uint8_t
|
||||
{
|
||||
ZoneBegin,
|
||||
ZoneEnd,
|
||||
StringData,
|
||||
NUM_TYPES
|
||||
};
|
||||
|
||||
@ -55,6 +56,7 @@ enum { QueueItemSize = sizeof( QueueItem ) };
|
||||
static const size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),
|
||||
sizeof( QueueHeader ),
|
||||
};
|
||||
|
||||
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
|
||||
|
Loading…
Reference in New Issue
Block a user