Commit 3bab334d authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

assume thread_local in SingletonThreadLocal

Differential Revision: D27582896

fbshipit-source-id: e4228117ba02fe18bd6e8964640f293c963a8732
parent 3cdd3009
......@@ -28,13 +28,6 @@
#include <folly/detail/UniqueInstance.h>
#include <folly/functional/Invoke.h>
// we do not want to use FOLLY_TLS here for mobile
#if !FOLLY_MOBILE && defined(FOLLY_TLS)
#define FOLLY_STL_USE_FOLLY_TLS 1
#else
#undef FOLLY_STL_USE_FOLLY_TLS
#endif
namespace folly {
/// SingletonThreadLocal
......@@ -147,7 +140,6 @@ class SingletonThreadLocal {
return *getWrapperTL();
}
#ifdef FOLLY_STL_USE_FOLLY_TLS
FOLLY_NOINLINE static Wrapper& getSlow(LocalCache& cache) {
if (threadlocal_detail::StaticMetaBase::dying()) {
return getWrapper();
......@@ -156,16 +148,14 @@ class SingletonThreadLocal {
lifetime.track(cache); // idempotent
return FOLLY_LIKELY(!!cache.cache) ? *cache.cache : getWrapper();
}
#endif
public:
FOLLY_EXPORT FOLLY_ALWAYS_INLINE static T& get() {
#ifdef FOLLY_STL_USE_FOLLY_TLS
if (kIsMobile) {
return getWrapper();
}
static thread_local LocalCache cache;
return FOLLY_LIKELY(!!cache.cache) ? *cache.cache : getSlow(cache);
#else
return getWrapper();
#endif
}
class Accessor {
......
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