Revert D6725091: [Folly] Use thread-local in RequestContext::getStaticContext
[folly.git] / folly / io / async / Request.cpp
index 644c208f18765c88453b55800d68732f761b469f..f8cca8b92a866c53bf34253fbf6ea96343208425 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() {