mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 18:11:33 +08:00
store thread_id in tls
This commit is contained in:
parent
343904b56d
commit
6d8efa8d7f
@ -294,7 +294,7 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
||||
|
||||
//Return current thread id as size_t
|
||||
//It exists because the std::this_thread::get_id() is much slower(espcially under VS 2013)
|
||||
inline size_t thread_id()
|
||||
inline size_t _thread_id()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return static_cast<size_t>(::GetCurrentThreadId());
|
||||
@ -310,10 +310,17 @@ inline size_t thread_id()
|
||||
#else //Default to standard C++11 (OSX and other Unix)
|
||||
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Return current thread id as size_t (from thread local storage)
|
||||
inline size_t thread_id()
|
||||
{
|
||||
static thread_local const size_t tid = _thread_id();
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
|
||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||
|
Loading…
Reference in New Issue
Block a user