mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Add unique event identifier source.
This commit is contained in:
parent
e4356eb67e
commit
05486c8225
@ -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(;;)
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user