diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 67a24a46..c8da39bd 100755 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -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() diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 0b3db95e..15a2b666 100755 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -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 m_shutdown;