Use producer tokens during event insertion.

This commit is contained in:
Bartosz Taudul 2017-09-10 20:52:10 +02:00
parent 452e5c5c83
commit 8d3aae24bf
2 changed files with 14 additions and 2 deletions

View File

@ -49,14 +49,19 @@ void Profiler::ZoneBegin( QueueZoneBegin&& data )
{
QueueItem item { QueueType::ZoneBegin, GetTime() };
item.zoneBegin = std::move( data );
s_instance->m_queue.enqueue( std::move( item ) );
s_instance->m_queue.enqueue( GetToken(), 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 ) );
s_instance->m_queue.enqueue( GetToken(), std::move( item ) );
}
Profiler* Profiler::Instance()
{
return s_instance;
}
void Profiler::Worker()

View File

@ -25,6 +25,13 @@ public:
private:
void Worker();
static Profiler* Instance();
static moodycamel::ProducerToken& GetToken()
{
static thread_local moodycamel::ProducerToken token( Instance()->m_queue );
return token;
}
int64_t m_timeBegin;
std::thread m_thread;
std::atomic<bool> m_shutdown;