}
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() {