Singleton allows for simple access to registering and instantiating singletons. Create instances of this class in the global scope of type Singleton<T> to register your singleton for later access via Singleton<T>::try_get().
Declared in <folly/Singleton.h>
template<
typename T,
typename Tag = /* implementation-defined */,
typename VaultTag = /* implementation-defined */>
class Singleton;
There are many supporting libraries and classes for Singleton; this is the one that users typically interact with.
| Name | Description |
|---|---|
CreateFunc | Create function used to build the singleton instance. |
TeardownFunc | Teardown function used to destroy the singleton instance. |
| Name | Description |
|---|---|
Singleton [constructor] | Constructors |
shouldEagerInit | Specify that the singleton should be eagerly initialized. |
shouldEagerInitOnReenable | Specify that the singleton should be eagerly initialized when singletons reenable. |
| Name | Description |
|---|---|
apply | Applies a callback to the possibly-nullptr singleton instance, returning the callback's result. |
get [deprecated] | Get a pointer to the singleton. |
get_weak [deprecated] | Get a weak_ptr to the singleton. |
make_mock | make_mock overloads |
try_get | Get a shared_ptr to the singleton. |
try_get_fast | Get a ReadMostlySharedPtr to the singleton. |
vivify | Ensure the instance exists. |