More meaningful thread id for OSX

This commit is contained in:
sheldonlyr 2017-06-24 15:38:18 +08:00
parent 1e4f14c789
commit 66a2c4993b

View File

@ -330,7 +330,11 @@ inline size_t _thread_id()
long tid; long tid;
thr_self(&tid); thr_self(&tid);
return static_cast<size_t>(tid); return static_cast<size_t>(tid);
#else //Default to standard C++11 (OSX and other Unix) #elif __APPLE__
uint64_t tid;
pthread_threadid_np(nullptr, &tid);
return static_cast<size_t>(tid);
#else //Default to standard C++11 (other Unix)
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id())); return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
#endif #endif
} }