From c2bd7be53da2470697729213308947e3467cedb5 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Tue, 6 Jun 2017 14:09:40 -0700 Subject: [PATCH] update TimeUtil to use getOSThreadID() Summary: Use the newly introduced getOSThreadID() function to get a thread ID for determining thread scheduling information on Linux. Reviewed By: yfeldblum Differential Revision: D5173596 fbshipit-source-id: 3e6fa352c3774986b0ac1f93bd6c7e4a29e08471 --- folly/io/async/test/TimeUtil.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/folly/io/async/test/TimeUtil.cpp b/folly/io/async/test/TimeUtil.cpp index 11187fbe..8312d9f8 100644 --- a/folly/io/async/test/TimeUtil.cpp +++ b/folly/io/async/test/TimeUtil.cpp @@ -23,7 +23,7 @@ #include #include #include -#ifndef _MSC_VER +#ifdef __linux__ #include #endif @@ -33,9 +33,8 @@ #include #include -#include +#include #include -#include #include @@ -44,19 +43,6 @@ using namespace std::chrono; namespace folly { -#ifdef _MSC_VER -static pid_t gettid() { - return pid_t(GetCurrentThreadId()); -} -#else -/** - * glibc doesn't provide gettid(), so define it ourselves. - */ -static pid_t gettid() { - return syscall(FOLLY_SYS_gettid); -} -#endif - static int getLinuxVersion(StringPiece release) { auto dot1 = release.find('.'); if (dot1 == StringPiece::npos) { @@ -231,7 +217,7 @@ void TimePoint::reset() { timeStart_ = system_clock::now(); // Remember how long this process has spent waiting to be scheduled - tid_ = gettid(); + tid_ = getOSThreadID(); timeWaiting_ = getTimeWaitingMS(tid_); // In case it took a while to read the schedstat info, -- 2.34.1