Allow queuing zones.

This commit is contained in:
Bartosz Taudul 2017-09-10 20:09:14 +02:00
parent 05486c8225
commit 12a6306c0b
2 changed files with 21 additions and 0 deletions

View File

@ -44,6 +44,20 @@ uint64_t Profiler::GetNewId()
return s_instance->m_id.fetch_add( 1, std::memory_order_relaxed );
}
void Profiler::ZoneBegin( QueueZoneBegin&& data )
{
QueueItem item { QueueType::ZoneBegin, GetTime() };
item.zoneBegin = std::move( data );
s_instance->m_queue.enqueue( std::move( item ) );
}
void Profiler::ZoneEnd( QueueZoneEnd&& data )
{
QueueItem item { QueueType::ZoneEnd, GetTime() };
item.zoneEnd = std::move( data );
s_instance->m_queue.enqueue( std::move( item ) );
}
void Profiler::Worker()
{
for(;;)

View File

@ -5,6 +5,9 @@
#include <stdint.h>
#include <thread>
#include "concurrentqueue.h"
#include "TracyQueue.hpp"
namespace tracy
{
@ -16,11 +19,15 @@ public:
static uint64_t GetNewId();
static void ZoneBegin( QueueZoneBegin&& data );
static void ZoneEnd( QueueZoneEnd&& data );
private:
void Worker();
std::thread m_thread;
std::atomic<bool> m_shutdown;
moodycamel::ConcurrentQueue<QueueItem> m_queue;
std::atomic<uint64_t> m_id;
};