From cf930032da9b0796d96c14c3b4446a75477c1ef3 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 16 Jan 2018 17:49:07 -0800 Subject: [PATCH] Revert D6725091: [Folly] Use thread-local in RequestContext::getStaticContext 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 | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/folly/io/async/Request.cpp b/folly/io/async/Request.cpp index 644c208f..f8cca8b9 100644 --- a/folly/io/async/Request.cpp +++ b/folly/io/async/Request.cpp @@ -141,16 +141,10 @@ std::shared_ptr RequestContext::setContext( } std::shared_ptr& RequestContext::getStaticContext() { - using T = std::shared_ptr; -#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 singleton; + using SingletonT = SingletonThreadLocal>; + static SingletonT singleton; + return singleton.get(); -#endif } RequestContext* RequestContext::get() { -- 2.34.1