proxygen
folly::detail::StaticSingletonManager Class Reference

#include <StaticSingletonManager.h>

Classes

struct  Creator
 
struct  TypePair
 

Static Public Member Functions

template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN Tcreate (F &&creator)
 

Private Types

using Key = std::type_info
 
using Make = void *(void *)
 

Static Private Member Functions

template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN void * create_ (F &creator)
 
template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN void * create_ (F const &creator)
 
static FOLLY_NOINLINE void * create_ (Key const &key, Make *make, void *ctx)
 

Detailed Description

Definition at line 30 of file StaticSingletonManager.h.

Member Typedef Documentation

using folly::detail::StaticSingletonManager::Key = std::type_info
private

Definition at line 42 of file StaticSingletonManager.h.

using folly::detail::StaticSingletonManager::Make = void*(void*)
private

Definition at line 43 of file StaticSingletonManager.h.

Member Function Documentation

template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN T* folly::detail::StaticSingletonManager::create ( F &&  creator)
inlinestatic

Definition at line 33 of file StaticSingletonManager.h.

References folly::T.

34  {
35  return static_cast<T*>(create_<T, Tag>(creator));
36  }
folly::std T
template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN void* folly::detail::StaticSingletonManager::create_ ( F &  creator)
inlinestaticprivate

Definition at line 53 of file StaticSingletonManager.h.

Referenced by create_().

54  {
55  auto const& key = typeid(TypePair<T, Tag>);
56  return create_(key, &Creator<F>::create, &creator);
57  }
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN void * create_(F &creator)
template<typename T , typename Tag , typename F >
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN void* folly::detail::StaticSingletonManager::create_ ( F const &  creator)
inlinestaticprivate

Definition at line 60 of file StaticSingletonManager.h.

References create_(), and FOLLY_NOINLINE.

61  {
62  auto const& key = typeid(TypePair<T, Tag>);
63  return create_(key, &Creator<F const>::create, const_cast<F*>(&creator));
64  }
FOLLY_ALWAYS_INLINE static FOLLY_ATTR_VISIBILITY_HIDDEN void * create_(F &creator)
void * folly::detail::StaticSingletonManager::create_ ( Key const &  key,
Make make,
void *  ctx 
)
staticprivate

Definition at line 54 of file StaticSingletonManager.cpp.

54  {
55  // This Leaky Meyers Singleton must always live in the .cpp file.
56  static auto& instance = *new StaticSingletonManagerImpl();
57  return instance.create(key, make, ctx);
58 }

The documentation for this class was generated from the following files: