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

Add inline function getCurrentThreadId

This commit is contained in:
Sergey Yagovtsev 2016-06-20 23:21:54 +03:00
parent e61404c92c
commit be11666ea3
3 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#include "profiler/profiler.h"
#include "profile_manager.h"
#include <ctime>
#include <chrono>
#include <thread>
@ -25,7 +25,7 @@ Block::Block(const char* _name, color_t _color, block_type_t _type) :
{
end = begin;
}
thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
thread_id = getCurrentThreadId();
}
void BaseBlockData::tick(timestamp_t& stamp)

View File

@ -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 <pthread.h>
#endif
uint32_t ProfileManager::getThreadId()
uint32_t getCurrentThreadId()
{
#ifdef WIN32
return (uint32_t)::GetCurrentThreadId();

View File

@ -27,6 +27,8 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#include <map>
#include <list>
inline uint32_t getCurrentThreadId();
class ProfileManager
{
ProfileManager();
@ -50,7 +52,7 @@ class ProfileManager
typedef std::list<profiler::SerilizedBlock*> serialized_list_t;
serialized_list_t m_blocks;
uint32_t getThreadId();
public:
static ProfileManager& instance();
~ProfileManager();