From: Yedidya Feldblum Date: Wed, 17 Jan 2018 01:49:07 +0000 (-0800) Subject: Revert D6725091: [Folly] Use thread-local in RequestContext::getStaticContext X-Git-Tag: v2018.01.22.00~27 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=cf930032da9b0796d96c14c3b4446a75477c1ef3;p=folly.git 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 --- 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() {