Add unique event identifier source.

This commit is contained in:
Bartosz Taudul 2017-09-10 20:08:42 +02:00
parent e4356eb67e
commit 05486c8225
2 changed files with 10 additions and 0 deletions

View File

@ -20,6 +20,7 @@ static Profiler* s_instance = nullptr;
Profiler::Profiler() Profiler::Profiler()
: m_shutdown( false ) : m_shutdown( false )
, m_id( 0 )
{ {
assert( PointerCheckA == PointerCheckB ); assert( PointerCheckA == PointerCheckB );
assert( !s_instance ); assert( !s_instance );
@ -38,6 +39,11 @@ Profiler::~Profiler()
m_thread.join(); m_thread.join();
} }
uint64_t Profiler::GetNewId()
{
return s_instance->m_id.fetch_add( 1, std::memory_order_relaxed );
}
void Profiler::Worker() void Profiler::Worker()
{ {
for(;;) for(;;)

View File

@ -2,6 +2,7 @@
#define __TRACYPROFILER_HPP__ #define __TRACYPROFILER_HPP__
#include <atomic> #include <atomic>
#include <stdint.h>
#include <thread> #include <thread>
namespace tracy namespace tracy
@ -13,11 +14,14 @@ public:
Profiler(); Profiler();
~Profiler(); ~Profiler();
static uint64_t GetNewId();
private: private:
void Worker(); void Worker();
std::thread m_thread; std::thread m_thread;
std::atomic<bool> m_shutdown; std::atomic<bool> m_shutdown;
std::atomic<uint64_t> m_id;
}; };
}; };