mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Send event data over network.
This commit is contained in:
parent
dbd25e2653
commit
8747da8e2c
@ -1,6 +1,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "../common/TracySocket.hpp"
|
||||||
#include "TracyProfiler.hpp"
|
#include "TracyProfiler.hpp"
|
||||||
#include "TracySystem.hpp"
|
#include "TracySystem.hpp"
|
||||||
|
|
||||||
@ -69,19 +71,37 @@ void Profiler::Worker()
|
|||||||
enum { BulkSize = 1024 };
|
enum { BulkSize = 1024 };
|
||||||
moodycamel::ConsumerToken token( m_queue );
|
moodycamel::ConsumerToken token( m_queue );
|
||||||
|
|
||||||
|
ListenSocket listen;
|
||||||
|
listen.Listen( "8086", 8 );
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
std::unique_ptr<Socket> sock;
|
||||||
|
for(;;)
|
||||||
QueueItem item[BulkSize];
|
|
||||||
const auto sz = m_queue.try_dequeue_bulk( token, item, BulkSize );
|
|
||||||
if( sz > 0 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
||||||
|
sock = listen.Accept();
|
||||||
|
if( sock ) break;
|
||||||
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sock->Send( &m_timeBegin, sizeof( m_timeBegin ) );
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
||||||
|
|
||||||
|
QueueItem item[BulkSize];
|
||||||
|
const auto sz = m_queue.try_dequeue_bulk( token, item, BulkSize );
|
||||||
|
if( sz > 0 )
|
||||||
|
{
|
||||||
|
if( sock->Send( item, sz * sizeof( QueueItem ) ) == -1 ) break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user