mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
View server skeleton.
This commit is contained in:
parent
45646c4f45
commit
953e9c6206
40
server/TracyView.cpp
Executable file
40
server/TracyView.cpp
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "../common/TracySystem.hpp"
|
||||||
|
#include "TracyView.hpp"
|
||||||
|
|
||||||
|
namespace tracy
|
||||||
|
{
|
||||||
|
|
||||||
|
static View* s_instance = nullptr;
|
||||||
|
|
||||||
|
View::View( const char* addr )
|
||||||
|
: m_addr( addr )
|
||||||
|
, m_shutdown( false )
|
||||||
|
{
|
||||||
|
assert( s_instance == nullptr );
|
||||||
|
s_instance = this;
|
||||||
|
|
||||||
|
m_thread = std::thread( [this] { Worker(); } );
|
||||||
|
SetThreadName( m_thread, "Tracy View" );
|
||||||
|
}
|
||||||
|
|
||||||
|
View::~View()
|
||||||
|
{
|
||||||
|
assert( s_instance != nullptr );
|
||||||
|
s_instance = nullptr;
|
||||||
|
|
||||||
|
m_shutdown.store( true, std::memory_order_relaxed );
|
||||||
|
m_thread.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::Worker()
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
||||||
|
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
server/TracyView.hpp
Executable file
29
server/TracyView.hpp
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef __TRACYVIEW_HPP__
|
||||||
|
#define __TRACYVIEW_HPP__
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
namespace tracy
|
||||||
|
{
|
||||||
|
|
||||||
|
class View
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
View() : View( "127.0.0.1" ) {}
|
||||||
|
View( const char* addr );
|
||||||
|
~View();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Worker();
|
||||||
|
|
||||||
|
std::string m_addr;
|
||||||
|
|
||||||
|
std::thread m_thread;
|
||||||
|
std::atomic<bool> m_shutdown;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user