Read QueueItems from network.

This commit is contained in:
Bartosz Taudul 2017-09-13 23:40:28 +02:00
parent 52d24d0d4c
commit 89dd244693
2 changed files with 39 additions and 2 deletions

View File

@ -6,8 +6,11 @@
#include <assert.h> #include <assert.h>
#include "../common/tracy_lz4.hpp"
#include "../common/TracyProtocol.hpp"
#include "../common/TracySocket.hpp" #include "../common/TracySocket.hpp"
#include "../common/TracySystem.hpp" #include "../common/TracySystem.hpp"
#include "../common/TracyQueue.hpp"
#include "TracyView.hpp" #include "TracyView.hpp"
namespace tracy namespace tracy
@ -61,8 +64,34 @@ void View::Worker()
for(;;) for(;;)
{ {
if( m_shutdown.load( std::memory_order_relaxed ) ) return; if( m_shutdown.load( std::memory_order_relaxed ) ) return;
char buf[16*1024];
if( sock.Recv( buf, 16*1024, &tv ) == 0 ) break; if( lz4 )
{
char buf[TargetFrameSize];
char lz4buf[LZ4Size];
lz4sz_t lz4sz;
if( !sock.Read( &lz4sz, sizeof( lz4sz ), &tv, ShouldExit ) ) goto close;
if( !sock.Read( lz4buf, lz4sz, &tv, ShouldExit ) ) goto close;
auto sz = LZ4_decompress_safe( lz4buf, buf, lz4sz, TargetFrameSize );
assert( sz >= 0 );
const char* ptr = buf;
const char* end = buf + sz;
while( ptr < end )
{
auto ev = (QueueItem*)ptr;
Process( *ev );
ptr += QueueDataSize[(uint8_t)ev->hdr.type];
}
}
else
{
QueueItem hdr;
if( !sock.Read( &hdr.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
if( !sock.Read( ((char*)&hdr) + sizeof( QueueHeader ), QueueDataSize[(uint8_t)hdr.hdr.type] - sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
Process( hdr );
}
} }
close: close:
@ -70,4 +99,9 @@ close:
} }
} }
void View::Process( const QueueItem& ev )
{
}
} }

View File

@ -8,6 +8,8 @@
namespace tracy namespace tracy
{ {
struct QueueItem;
class View class View
{ {
public: public:
@ -19,6 +21,7 @@ public:
private: private:
void Worker(); void Worker();
void Process( const QueueItem& ev );
std::string m_addr; std::string m_addr;