diff --git a/src/block.cpp b/src/block.cpp index 354de61..f887cb0 100644 --- a/src/block.cpp +++ b/src/block.cpp @@ -1,5 +1,5 @@ #include "profiler/profiler.h" - +#include "profile_manager.h" #include #include #include @@ -25,7 +25,7 @@ Block::Block(const char* _name, color_t _color, block_type_t _type) : { end = begin; } - thread_id = std::hash()(std::this_thread::get_id()); + thread_id = getCurrentThreadId(); } void BaseBlockData::tick(timestamp_t& stamp) diff --git a/src/profile_manager.cpp b/src/profile_manager.cpp index 769ce67..488e6fe 100644 --- a/src/profile_manager.cpp +++ b/src/profile_manager.cpp @@ -122,7 +122,7 @@ void ProfileManager::endBlock() if (!m_isEnabled) return; - uint32_t threadId = getThreadId(); + uint32_t threadId = getCurrentThreadId(); guard_lock_t lock(m_spin); auto& stackOfOpenedBlocks = m_openedBracketsMap[threadId]; @@ -156,7 +156,7 @@ void ProfileManager::_internalInsertBlock(profiler::Block* _block) #include #endif -uint32_t ProfileManager::getThreadId() +uint32_t getCurrentThreadId() { #ifdef WIN32 return (uint32_t)::GetCurrentThreadId(); diff --git a/src/profile_manager.h b/src/profile_manager.h index eb33bfa..ec2c7e9 100644 --- a/src/profile_manager.h +++ b/src/profile_manager.h @@ -27,6 +27,8 @@ along with this program.If not, see . #include #include +inline uint32_t getCurrentThreadId(); + class ProfileManager { ProfileManager(); @@ -50,7 +52,7 @@ class ProfileManager typedef std::list serialized_list_t; serialized_list_t m_blocks; - uint32_t getThreadId(); + public: static ProfileManager& instance(); ~ProfileManager();