Commit cf930032 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

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
parent 8893b8bc
...@@ -141,16 +141,10 @@ std::shared_ptr<RequestContext> RequestContext::setContext( ...@@ -141,16 +141,10 @@ std::shared_ptr<RequestContext> RequestContext::setContext(
} }
std::shared_ptr<RequestContext>& RequestContext::getStaticContext() { std::shared_ptr<RequestContext>& RequestContext::getStaticContext() {
using T = std::shared_ptr<RequestContext>; using SingletonT = SingletonThreadLocal<std::shared_ptr<RequestContext>>;
#ifdef FOLLY_TLS static SingletonT singleton;
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;
return singleton.get(); return singleton.get();
#endif
} }
RequestContext* RequestContext::get() { RequestContext* RequestContext::get() {
......
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