mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-28 01:04:41 +08:00
Add function getThreadId
This commit is contained in:
parent
34307baca1
commit
e61404c92c
@ -116,15 +116,14 @@ void ProfileManager::beginBlock(Block* _block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileManager::endBlock()
|
void ProfileManager::endBlock()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!m_isEnabled)
|
if (!m_isEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t threadId = std::hash<std::thread::id>()(std::this_thread::get_id());
|
uint32_t threadId = getThreadId();
|
||||||
|
|
||||||
guard_lock_t lock(m_spin);
|
guard_lock_t lock(m_spin);
|
||||||
auto& stackOfOpenedBlocks = m_openedBracketsMap[threadId];
|
auto& stackOfOpenedBlocks = m_openedBracketsMap[threadId];
|
||||||
|
|
||||||
@ -151,3 +150,17 @@ void ProfileManager::_internalInsertBlock(profiler::Block* _block)
|
|||||||
m_blocks.emplace_back(new SerilizedBlock(_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
|
||||||
|
}
|
||||||
|
@ -49,6 +49,8 @@ class ProfileManager
|
|||||||
|
|
||||||
typedef std::list<profiler::SerilizedBlock*> serialized_list_t;
|
typedef std::list<profiler::SerilizedBlock*> serialized_list_t;
|
||||||
serialized_list_t m_blocks;
|
serialized_list_t m_blocks;
|
||||||
|
|
||||||
|
uint32_t getThreadId();
|
||||||
public:
|
public:
|
||||||
static ProfileManager& instance();
|
static ProfileManager& instance();
|
||||||
~ProfileManager();
|
~ProfileManager();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user