proxygen
|
#include <Singleton.h>
Public Types | |
typedef std::function< T *(void)> | CreateFunc |
typedef std::function< void(T *)> | TeardownFunc |
Public Member Functions | |
Singleton (std::nullptr_t=nullptr, typename Singleton::TeardownFunc t=nullptr) | |
Singleton (typename Singleton::CreateFunc c, typename Singleton::TeardownFunc t=nullptr) | |
Singleton & | shouldEagerInit () |
Static Public Member Functions | |
static T * | get () |
static std::weak_ptr< T > | get_weak () |
static std::shared_ptr< T > | try_get () |
static folly::ReadMostlySharedPtr< T > | try_get_fast () |
static void | vivify () |
static void | make_mock (std::nullptr_t=nullptr, typename Singleton< T >::TeardownFunc t=nullptr) |
static void | make_mock (CreateFunc c, typename Singleton< T >::TeardownFunc t=nullptr) |
Static Private Member Functions | |
static detail::SingletonHolder< T > & | getEntry () |
static detail::SingletonHolder< T >::TeardownFunc | getTeardownFunc (TeardownFunc t) |
Definition at line 571 of file Singleton.h.
typedef std::function<T*(void)> folly::Singleton< T, Tag, VaultTag >::CreateFunc |
Definition at line 573 of file Singleton.h.
typedef std::function<void(T*)> folly::Singleton< T, Tag, VaultTag >::TeardownFunc |
Definition at line 574 of file Singleton.h.
|
inlineexplicit |
Definition at line 611 of file Singleton.h.
|
inlineexplicit |
Definition at line 616 of file Singleton.h.
|
inlinestatic |
Definition at line 579 of file Singleton.h.
Referenced by follySingletonRaw().
|
inlinestatic |
Definition at line 587 of file Singleton.h.
Referenced by TEST().
|
inlinestaticprivate |
Definition at line 679 of file Singleton.h.
|
inlinestaticprivate |
Definition at line 684 of file Singleton.h.
|
inlinestatic |
Construct and inject a mock singleton which should be used only from tests. Unlike regular singletons which are initialized once per process lifetime, mock singletons live for the duration of a test. This means that one process running multiple tests can initialize and register the same singleton multiple times. This functionality should be used only from tests since it relaxes validation and performance in order to be able to perform the injection. The returned mock singleton is functionality identical to regular singletons.
Definition at line 660 of file Singleton.h.
Referenced by TEST().
|
inlinestatic |
Definition at line 666 of file Singleton.h.
|
inline |
Should be instantiated as soon as "doEagerInit[Via]" is called. Singletons are usually lazy-loaded (built on-demand) but for those which are known to be needed, to avoid the potential lag for objects that take long to construct during runtime, there is an option to make sure these are built up-front.
Use like: Singleton<Foo> gFooInstance = Singleton<Foo>(...).shouldEagerInit();
Or alternately, define the singleton as usual, and say gFooInstance.shouldEagerInit();
at some point prior to calling registrationComplete(). Then doEagerInit() or doEagerInitVia(Executor*) can be called.
Definition at line 644 of file Singleton.h.
|
inlinestatic |
Definition at line 598 of file Singleton.h.
Referenced by follySingletonTryGet(), NeedySingleton::NeedySingleton(), SelfNeedySingleton::SelfNeedySingleton(), SlowpokeNeedySingleton::SlowpokeNeedySingleton(), TEST(), and folly::tryGetShutdownSocketSet().
|
inlinestatic |
Definition at line 602 of file Singleton.h.
Referenced by follySingletonTryGetFast(), TEST(), and folly::tryGetShutdownSocketSetFast().
|
inlinestatic |
Definition at line 607 of file Singleton.h.