From 8747da8e2c8e0f9447cc98ce104e3339237b7329 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 11 Sep 2017 22:51:47 +0200 Subject: [PATCH] Send event data over network. --- client/TracyProfiler.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index c8da39bd..38041c72 100755 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1,6 +1,8 @@ #include #include +#include +#include "../common/TracySocket.hpp" #include "TracyProfiler.hpp" #include "TracySystem.hpp" @@ -69,19 +71,37 @@ void Profiler::Worker() enum { BulkSize = 1024 }; moodycamel::ConsumerToken token( m_queue ); + ListenSocket listen; + listen.Listen( "8086", 8 ); + 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 ) - { - } - else + std::unique_ptr sock; + for(;;) { + if( m_shutdown.load( std::memory_order_relaxed ) ) return; + sock = listen.Accept(); + if( sock ) break; 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 ) ); + } + } } }