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
#include <string>
#include <type_traits>
#include <vector>
-#include <pthread.h>
+
#include <folly/Hash.h>
#include <folly/Likely.h>
#include <folly/Portability.h>
+#include <folly/ThreadId.h>
namespace folly {
namespace detail {
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());
}
};