mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 10:29:02 +08:00
Fix Visual Studio poor std::this_thread::get_id() performance by using GetCurrentThreadId() (and pthread_self() under linux)
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <Windows.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include "../common.h"
|
||||
@@ -167,6 +169,17 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
||||
}
|
||||
|
||||
|
||||
inline uint64_t thread_id()
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
return ::GetCurrentThreadId();
|
||||
#else
|
||||
return (uint64_t) pthread_self();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
} //os
|
||||
} //details
|
||||
} //spdlog
|
||||
|
Reference in New Issue
Block a user