mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Basic receive loop.
This commit is contained in:
parent
365f2cde23
commit
afde32549d
@ -1,5 +1,12 @@
|
|||||||
|
#ifdef _MSC_VER
|
||||||
|
# include <winsock2.h>
|
||||||
|
#else
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "../common/TracySocket.hpp"
|
||||||
#include "../common/TracySystem.hpp"
|
#include "../common/TracySystem.hpp"
|
||||||
#include "TracyView.hpp"
|
#include "TracyView.hpp"
|
||||||
|
|
||||||
@ -30,10 +37,30 @@ View::~View()
|
|||||||
|
|
||||||
void View::Worker()
|
void View::Worker()
|
||||||
{
|
{
|
||||||
|
Socket sock;
|
||||||
|
|
||||||
|
timeval tv;
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 10000;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ private:
|
|||||||
|
|
||||||
std::thread m_thread;
|
std::thread m_thread;
|
||||||
std::atomic<bool> m_shutdown;
|
std::atomic<bool> m_shutdown;
|
||||||
|
|
||||||
|
int64_t m_timeBegin;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user