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

Thread local for get current thread id

This commit is contained in:
Sergey Yagovtsev 2016-06-22 23:57:11 +03:00
parent 99fa9ffc5d
commit fb3837316c

View File

@ -38,7 +38,8 @@ inline uint32_t getCurrentThreadId()
#ifdef WIN32
return (uint32_t)::GetCurrentThreadId();
#else
return (uint32_t)std::hash<std::thread::id>()(std::this_thread::get_id());
thread_local static uint32_t _id = (uint32_t)std::hash<std::thread::id>()(std::this_thread::get_id());
return _id;
#endif
}