Commit 01de3b43 authored by Andrew Krieger's avatar Andrew Krieger Committed by Facebook Github Bot

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
parent 4e509c4b
...@@ -24,10 +24,11 @@ ...@@ -24,10 +24,11 @@
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
#include <pthread.h>
#include <folly/Hash.h> #include <folly/Hash.h>
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/Portability.h> #include <folly/Portability.h>
#include <folly/ThreadId.h>
namespace folly { namespace folly {
namespace detail { namespace detail {
...@@ -174,10 +175,7 @@ extern template struct SequentialThreadId<std::atomic>; ...@@ -174,10 +175,7 @@ extern template struct SequentialThreadId<std::atomic>;
struct HashingThreadId { struct HashingThreadId {
static unsigned get() { static unsigned get() {
pthread_t pid = pthread_self(); return hash::twang_32from64(getCurrentThreadID());
uint64_t id = 0;
memcpy(&id, &pid, std::min(sizeof(pid), sizeof(id)));
return hash::twang_32from64(id);
} }
}; };
......
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