Use getCurrentThreadID() rather than pthread_self() in MemoryIdler
authorChristopher Dykes <cdykes@fb.com>
Fri, 14 Apr 2017 04:19:08 +0000 (21:19 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 14 Apr 2017 04:20:15 +0000 (21:20 -0700)
Summary: Ignoring the questionability of the approach it's being used in, it's better to not have the direct PThread dependency.

Reviewed By: yfeldblum

Differential Revision: D4889245

fbshipit-source-id: da099c6f938dbe98c1b9eeaf4de0a27a2c4d65f1

folly/detail/MemoryIdler.h

index 324afac4f0e9837aeedfbf19bab0bc982c08259e..f6694fa5c8d2ad91af5655a01788f9b1f25eaf07 100644 (file)
@@ -20,9 +20,9 @@
 #include <chrono>
 #include <folly/AtomicStruct.h>
 #include <folly/Hash.h>
+#include <folly/ThreadId.h>
 #include <folly/Traits.h>
 #include <folly/detail/Futex.h>
-#include <folly/portability/PThread.h>
 
 namespace folly {
 
@@ -85,7 +85,7 @@ struct MemoryIdler {
     if (idleTimeout.count() > 0 && timeoutVariationFrac > 0) {
       // hash the pthread_t and the time to get the adjustment.
       // Standard hash func isn't very good, so bit mix the result
-      auto pr = std::make_pair(pthread_self(),
+      auto pr = std::make_pair(getCurrentThreadID(),
                                Clock::now().time_since_epoch().count());
       std::hash<decltype(pr)> hash_fn;
       uint64_t h = folly::hash::twang_mix64(hash_fn(pr));