Profiler worker thread skeleton.

This commit is contained in:
Bartosz Taudul 2017-09-10 17:43:56 +02:00
parent a2849002ec
commit a5d6039aea
2 changed files with 61 additions and 0 deletions

36
client/TracyProfiler.cpp Executable file
View File

@ -0,0 +1,36 @@
#include <assert.h>
#include "TracyProfiler.hpp"
namespace tracy
{
static Profiler* s_instance = nullptr;
Profiler::Profiler()
: m_shutdown( false )
{
assert( !s_instance );
s_instance = this;
m_thread = std::thread( [this] { Worker(); } );
}
Profiler::~Profiler()
{
assert( s_instance );
s_instance = nullptr;
m_shutdown.store( true, std::memory_order_relaxed );
m_thread.join();
}
void Profiler::Worker()
{
for(;;)
{
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
}
}
}

25
client/TracyProfiler.hpp Executable file
View File

@ -0,0 +1,25 @@
#ifndef __TRACYPROFILER_HPP__
#define __TRACYPROFILER_HPP__
#include <atomic>
#include <thread>
namespace tracy
{
class Profiler
{
public:
Profiler();
~Profiler();
private:
void Worker();
std::thread m_thread;
std::atomic<bool> m_shutdown;
};
};
#endif