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

Get thread id on linux by syscall instead of std::this_thread

This commit is contained in:
Sergey Yagovtsev 2016-09-05 22:02:32 +03:00
parent f5ed51e13a
commit 6d1b9915d2

View File

@ -36,6 +36,9 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#include <Windows.h>
#else
#include <thread>
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
#endif
inline uint32_t getCurrentThreadId()
@ -43,7 +46,8 @@ inline uint32_t getCurrentThreadId()
#ifdef _WIN32
return (uint32_t)::GetCurrentThreadId();
#else
thread_local static uint32_t _id = (uint32_t)std::hash<std::thread::id>()(std::this_thread::get_id());
thread_local static pid_t x = syscall(__NR_gettid);
thread_local static uint32_t _id = (uint32_t)x;//std::hash<std::thread::id>()(std::this_thread::get_id());
return _id;
#endif
}