Commit 7d3bbfee authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 0

Use std::thread::id in Fiber rather than a syscall

Summary: syscall() doesn't exist on Windows, but std::thread::id is standardized, and can do what we need it for, so use it instead.

Reviewed By: yfeldblum

Differential Revision: D3256064

fb-gh-sync-id: efddac82c117ccd8a53c8c93248529000b4326a5
fbshipit-source-id: efddac82c117ccd8a53c8c93248529000b4326a5
parent 36f174f9
......@@ -35,14 +35,8 @@ namespace fibers {
namespace {
static const uint64_t kMagic8Bytes = 0xfaceb00cfaceb00c;
pid_t localThreadId() {
// __thread doesn't allow non-const initialization.
// OSX doesn't support thread_local.
static FOLLY_TLS pid_t threadId = 0;
if (UNLIKELY(threadId == 0)) {
threadId = syscall(FOLLY_SYS_gettid);
}
return threadId;
std::thread::id localThreadId() {
return std::this_thread::get_id();
}
/* Size of the region from p + nBytes down to the last non-magic value */
......
......@@ -184,7 +184,7 @@ class Fiber {
folly::IntrusiveListHook listHook_; /**< list hook for different FiberManager
queues */
folly::IntrusiveListHook globalListHook_; /**< list hook for global list */
pid_t threadId_{0};
std::thread::id threadId_{};
};
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment