mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-29 16:54:35 +00:00
Make View socket available to every method in class.
This commit is contained in:
parent
ef7dca9073
commit
b9c76f3452
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "../common/tracy_lz4.hpp"
|
#include "../common/tracy_lz4.hpp"
|
||||||
#include "../common/TracyProtocol.hpp"
|
#include "../common/TracyProtocol.hpp"
|
||||||
#include "../common/TracySocket.hpp"
|
|
||||||
#include "../common/TracySystem.hpp"
|
#include "../common/TracySystem.hpp"
|
||||||
#include "../common/TracyQueue.hpp"
|
#include "../common/TracyQueue.hpp"
|
||||||
#include "TracyView.hpp"
|
#include "TracyView.hpp"
|
||||||
@ -45,8 +44,6 @@ bool View::ShouldExit()
|
|||||||
|
|
||||||
void View::Worker()
|
void View::Worker()
|
||||||
{
|
{
|
||||||
Socket sock;
|
|
||||||
|
|
||||||
timeval tv;
|
timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 10000;
|
tv.tv_usec = 10000;
|
||||||
@ -54,12 +51,12 @@ void View::Worker()
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
||||||
if( !sock.Connect( m_addr.c_str(), "8086" ) ) continue;
|
if( !m_sock.Connect( m_addr.c_str(), "8086" ) ) continue;
|
||||||
|
|
||||||
uint8_t lz4;
|
uint8_t lz4;
|
||||||
|
|
||||||
if( !sock.Read( &m_timeBegin, sizeof( m_timeBegin ), &tv, ShouldExit ) ) goto close;
|
if( !m_sock.Read( &m_timeBegin, sizeof( m_timeBegin ), &tv, ShouldExit ) ) goto close;
|
||||||
if( !sock.Read( &lz4, sizeof( lz4 ), &tv, ShouldExit ) ) goto close;
|
if( !m_sock.Read( &lz4, sizeof( lz4 ), &tv, ShouldExit ) ) goto close;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
@ -70,8 +67,8 @@ void View::Worker()
|
|||||||
char buf[TargetFrameSize];
|
char buf[TargetFrameSize];
|
||||||
char lz4buf[LZ4Size];
|
char lz4buf[LZ4Size];
|
||||||
lz4sz_t lz4sz;
|
lz4sz_t lz4sz;
|
||||||
if( !sock.Read( &lz4sz, sizeof( lz4sz ), &tv, ShouldExit ) ) goto close;
|
if( !m_sock.Read( &lz4sz, sizeof( lz4sz ), &tv, ShouldExit ) ) goto close;
|
||||||
if( !sock.Read( lz4buf, lz4sz, &tv, ShouldExit ) ) goto close;
|
if( !m_sock.Read( lz4buf, lz4sz, &tv, ShouldExit ) ) goto close;
|
||||||
|
|
||||||
auto sz = LZ4_decompress_safe( lz4buf, buf, lz4sz, TargetFrameSize );
|
auto sz = LZ4_decompress_safe( lz4buf, buf, lz4sz, TargetFrameSize );
|
||||||
assert( sz >= 0 );
|
assert( sz >= 0 );
|
||||||
@ -88,14 +85,14 @@ void View::Worker()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QueueItem ev;
|
QueueItem ev;
|
||||||
if( !sock.Read( &ev.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
|
if( !m_sock.Read( &ev.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
|
||||||
if( !sock.Read( ((char*)&ev) + sizeof( QueueHeader ), QueueDataSize[ev.hdr.idx] - sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
|
if( !m_sock.Read( ((char*)&ev) + sizeof( QueueHeader ), QueueDataSize[ev.hdr.idx] - sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
|
||||||
Process( ev );
|
Process( ev );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close:
|
close:
|
||||||
sock.Close();
|
m_sock.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../common/TracySocket.hpp"
|
||||||
#include "../common/TracyQueue.hpp"
|
#include "../common/TracyQueue.hpp"
|
||||||
#include "TracyEvent.hpp"
|
#include "TracyEvent.hpp"
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ private:
|
|||||||
|
|
||||||
std::string m_addr;
|
std::string m_addr;
|
||||||
|
|
||||||
|
Socket m_sock;
|
||||||
std::thread m_thread;
|
std::thread m_thread;
|
||||||
std::atomic<bool> m_shutdown;
|
std::atomic<bool> m_shutdown;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user