From: Christopher Dykes Date: Fri, 14 Apr 2017 04:19:08 +0000 (-0700) Subject: Use getCurrentThreadID() rather than pthread_self() in MemoryIdler X-Git-Tag: v2017.04.17.00~16 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=04de301e53306065da021bcda8fc48b9030cbd25;p=folly.git Use getCurrentThreadID() rather than pthread_self() in MemoryIdler 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 --- diff --git a/folly/detail/MemoryIdler.h b/folly/detail/MemoryIdler.h index 324afac4..f6694fa5 100644 --- a/folly/detail/MemoryIdler.h +++ b/folly/detail/MemoryIdler.h @@ -20,9 +20,9 @@ #include #include #include +#include #include #include -#include 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 hash_fn; uint64_t h = folly::hash::twang_mix64(hash_fn(pr));