From 01de3b4373aee3e7f53c0b469fb8d50d71b87b35 Mon Sep 17 00:00:00 2001 From: Andrew Krieger Date: Thu, 13 Apr 2017 22:57:20 -0700 Subject: [PATCH] Remove pthread dependency from CacheLocality.h Summary: For getting a thread id for hashing, std::this_thread::get_id() is just as good and also removes an unneeded pthreads dependency. This enables using MPMCQueue on Windows without pthreads as well. Reviewed By: Orvid, yfeldblum Differential Revision: D4879940 fbshipit-source-id: c4fb5eea165eb450240f94904aa26a10aa394d1b --- folly/detail/CacheLocality.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/folly/detail/CacheLocality.h b/folly/detail/CacheLocality.h index 965387b6..617182d5 100644 --- a/folly/detail/CacheLocality.h +++ b/folly/detail/CacheLocality.h @@ -24,10 +24,11 @@ #include #include #include -#include + #include #include #include +#include namespace folly { namespace detail { @@ -174,10 +175,7 @@ extern template struct SequentialThreadId; struct HashingThreadId { static unsigned get() { - pthread_t pid = pthread_self(); - uint64_t id = 0; - memcpy(&id, &pid, std::min(sizeof(pid), sizeof(id))); - return hash::twang_32from64(id); + return hash::twang_32from64(getCurrentThreadID()); } }; -- 2.34.1