From afde32549d2f3f9557c276db9c20db88ac2d587d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 13 Sep 2017 01:54:22 +0200 Subject: [PATCH] Basic receive loop. --- server/TracyView.cpp | 29 ++++++++++++++++++++++++++++- server/TracyView.hpp | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index ec0add6c..db07addc 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -1,5 +1,12 @@ +#ifdef _MSC_VER +# include +#else +# include +#endif + #include +#include "../common/TracySocket.hpp" #include "../common/TracySystem.hpp" #include "TracyView.hpp" @@ -30,10 +37,30 @@ View::~View() void View::Worker() { + Socket sock; + + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 10000; + for(;;) { if( m_shutdown.load( std::memory_order_relaxed ) ) return; - std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); + if( !sock.Connect( m_addr.c_str(), "8086" ) ) continue; + + sock.Recv( &m_timeBegin, sizeof( m_timeBegin ), nullptr ); + + uint8_t lz4; + sock.Recv( &lz4, 1, nullptr ); + + for(;;) + { + if( m_shutdown.load( std::memory_order_relaxed ) ) return; + char buf[16*1024]; + if( sock.Recv( buf, 16*1024, &tv ) == 0 ) break; + } + + sock.Close(); } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 72d1585b..a2ec514b 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -22,6 +22,8 @@ private: std::thread m_thread; std::atomic m_shutdown; + + int64_t m_timeBegin; }; }