Revert D6725091: [Folly] Use thread-local in RequestContext::getStaticContext
authorYedidya Feldblum <yfeldblum@fb.com>
Wed, 17 Jan 2018 01:49:07 +0000 (17:49 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 17 Jan 2018 01:50:45 +0000 (17:50 -0800)
Summary:
This reverts commit 9979f39677284b1051cb109b461097495d77ca17

bypass-lint

An infra SEV is better than not reverting this diff.
If you copy this password, see you in SEV Review!
cause_a_sev_many_files

Differential Revision: D6725091

fbshipit-source-id: f1e3c80c869aa47684f5fbe79528e68174dee568

folly/io/async/Request.cpp

index 644c208..f8cca8b 100644 (file)
@@ -141,16 +141,10 @@ std::shared_ptr<RequestContext> RequestContext::setContext(
 }
 
 std::shared_ptr<RequestContext>& RequestContext::getStaticContext() {
-  using T = std::shared_ptr<RequestContext>;
-#ifdef FOLLY_TLS
-  alignas(alignof(T)) static FOLLY_TLS unsigned char storage[sizeof(T)];
-  static FOLLY_TLS T* singleton;
-  return singleton ? *singleton : *(singleton = new (storage) T());
-#else
-  struct PrivateTag {};
-  static SingletonThreadLocal<T, PrivateTag> singleton;
+  using SingletonT = SingletonThreadLocal<std::shared_ptr<RequestContext>>;
+  static SingletonT singleton;
+
   return singleton.get();
-#endif
 }
 
 RequestContext* RequestContext::get() {