0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

Add function getThreadId

This commit is contained in:
Sergey Yagovtsev 2016-06-20 23:10:14 +03:00
parent 34307baca1
commit e61404c92c
2 changed files with 18 additions and 3 deletions

View File

@ -116,15 +116,14 @@ void ProfileManager::beginBlock(Block* _block)
}
}
void ProfileManager::endBlock()
{
if (!m_isEnabled)
return;
uint32_t threadId = std::hash<std::thread::id>()(std::this_thread::get_id());
uint32_t threadId = getThreadId();
guard_lock_t lock(m_spin);
auto& stackOfOpenedBlocks = m_openedBracketsMap[threadId];
@ -151,3 +150,17 @@ void ProfileManager::_internalInsertBlock(profiler::Block* _block)
m_blocks.emplace_back(new SerilizedBlock(_block));
}
#ifdef WIN32
#include <Windows.h>
#else
#include <pthread.h>
#endif
uint32_t ProfileManager::getThreadId()
{
#ifdef WIN32
return (uint32_t)::GetCurrentThreadId();
#else
return (uint32_t)pthread_self();
#endif
}

View File

@ -49,6 +49,8 @@ class ProfileManager
typedef std::list<profiler::SerilizedBlock*> serialized_list_t;
serialized_list_t m_blocks;
uint32_t getThreadId();
public:
static ProfileManager& instance();
~ProfileManager();