mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
Get thread id on linux by syscall instead of std::this_thread
This commit is contained in:
parent
f5ed51e13a
commit
6d1b9915d2
@ -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,8 +46,9 @@ 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());
|
||||
return _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
|
||||
}
|
||||
|
||||
@ -108,8 +112,8 @@ class ThreadStorage final
|
||||
uint64_t usedMemorySize = 0;
|
||||
|
||||
void clearClosed() {
|
||||
serialized_list_t().swap(closedList);
|
||||
alloc.clear();
|
||||
serialized_list_t().swap(closedList);
|
||||
alloc.clear();
|
||||
usedMemorySize = 0;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user