proxygen
|
#include <Singleton.h>
Public Types | |
typedef std::function< void(T *)> | TeardownFunc |
typedef std::function< T *(void)> | CreateFunc |
Public Member Functions | |
T * | get () |
std::weak_ptr< T > | get_weak () |
std::shared_ptr< T > | try_get () |
folly::ReadMostlySharedPtr< T > | try_get_fast () |
void | vivify () |
void | registerSingleton (CreateFunc c, TeardownFunc t) |
void | registerSingletonMock (CreateFunc c, TeardownFunc t) |
bool | hasLiveInstance () override |
void | createInstance () override |
bool | creationStarted () override |
void | preDestroyInstance (ReadMostlyMainPtrDeleter<> &) override |
void | destroyInstance () override |
Public Member Functions inherited from folly::detail::SingletonHolderBase | |
SingletonHolderBase (TypeDescriptor typeDesc) | |
virtual | ~SingletonHolderBase ()=default |
TypeDescriptor | type () const |
Static Public Member Functions | |
template<typename Tag , typename VaultTag > | |
static SingletonHolder< T > & | singleton () |
Private Types | |
enum | SingletonHolderState { SingletonHolderState::NotRegistered, SingletonHolderState::Dead, SingletonHolderState::Living } |
Private Member Functions | |
SingletonHolder (TypeDescriptor type, SingletonVault &vault) | |
SingletonHolder (const SingletonHolder &)=delete | |
SingletonHolder & | operator= (const SingletonHolder &)=delete |
SingletonHolder & | operator= (SingletonHolder &&)=delete |
SingletonHolder (SingletonHolder &&)=delete | |
Private Attributes | |
SingletonVault & | vault_ |
std::mutex | mutex_ |
std::atomic< SingletonHolderState > | state_ {SingletonHolderState::NotRegistered} |
std::atomic< std::thread::id > | creating_thread_ {} |
folly::ReadMostlyMainPtr< T > | instance_ |
folly::ReadMostlySharedPtr< T > | instance_copy_ |
std::weak_ptr< T > | instance_weak_ |
folly::ReadMostlyWeakPtr< T > | instance_weak_fast_ |
std::shared_ptr< folly::Baton<> > | destroy_baton_ |
T * | instance_ptr_ = nullptr |
CreateFunc | create_ = nullptr |
TeardownFunc | teardown_ = nullptr |
std::shared_ptr< std::atomic< bool > > | print_destructor_stack_trace_ |
Definition at line 302 of file Singleton.h.
typedef std::function<T*(void)> folly::detail::SingletonHolder< T >::CreateFunc |
Definition at line 305 of file Singleton.h.
typedef std::function<void(T*)> folly::detail::SingletonHolder< T >::TeardownFunc |
Definition at line 304 of file Singleton.h.
|
strongprivate |
Enumerator | |
---|---|
NotRegistered | |
Dead | |
Living |
Definition at line 327 of file Singleton.h.
|
private |
Definition at line 181 of file Singleton-inl.h.
|
privatedelete |
|
privatedelete |
|
overridevirtual |
Implements folly::detail::SingletonHolderBase.
Definition at line 203 of file Singleton-inl.h.
References folly::detail::SingletonHolder< T >::create_, folly::detail::SingletonHolder< T >::creating_thread_, folly::SingletonVault::creationOrder_, folly::detail::SingletonHolder< T >::destroy_baton_, folly::detail::SingletonHolder< T >::instance_, folly::detail::SingletonHolder< T >::instance_ptr_, folly::detail::SingletonHolder< T >::instance_weak_, folly::detail::SingletonHolder< T >::instance_weak_fast_, folly::detail::SingletonHolder< T >::Living, folly::gen::move, folly::detail::SingletonHolder< T >::mutex_, folly::detail::SingletonHolder< T >::NotRegistered, folly::detail::SingletonHolder< T >::print_destructor_stack_trace_, folly::detail::SingletonVaultState::Quiescing, folly::SingletonVault::Relaxed, folly::ReadMostlyMainPtr< T, RefCount >::reset(), folly::SingletonVault::scheduleDestroyInstances(), SCOPE_EXIT, folly::detail::singletonPrintDestructionStackTrace(), folly::detail::singletonWarnCreateBeforeRegistrationCompleteAndAbort(), folly::detail::singletonWarnCreateCircularDependencyAndAbort(), folly::detail::singletonWarnCreateUnregisteredAndAbort(), folly::detail::SingletonHolder< T >::state_, folly::SingletonVault::state_, folly::T, folly::detail::SingletonHolderBase::type(), folly::SingletonVault::type_, and folly::detail::SingletonHolder< T >::vault_.
|
overridevirtual |
Implements folly::detail::SingletonHolderBase.
Definition at line 187 of file Singleton-inl.h.
References folly::detail::SingletonHolder< T >::creating_thread_, folly::detail::SingletonHolder< T >::Living, and folly::detail::SingletonHolder< T >::state_.
|
overridevirtual |
Implements folly::detail::SingletonHolderBase.
Definition at line 163 of file Singleton-inl.h.
References folly::detail::singletonWarnDestroyInstanceLeak(), and type.
|
inline |
Definition at line 93 of file Singleton-inl.h.
References LIKELY, folly::detail::singletonThrowGetInvokedAfterDestruction(), and type.
|
inline |
Definition at line 109 of file Singleton-inl.h.
References UNLIKELY.
|
overridevirtual |
Implements folly::detail::SingletonHolderBase.
Definition at line 151 of file Singleton-inl.h.
|
privatedelete |
|
privatedelete |
|
overridevirtual |
Implements folly::detail::SingletonHolderBase.
Definition at line 156 of file Singleton-inl.h.
References folly::ReadMostlyMainPtrDeleter< RefCount >::add(), and folly::gen::move.
void folly::detail::SingletonHolder< T >::registerSingleton | ( | CreateFunc | c, |
TeardownFunc | t | ||
) |
Definition at line 36 of file Singleton-inl.h.
References folly::gen::move, mutex_, folly::detail::singletonWarnDoubleRegistrationAndAbort(), and type.
void folly::detail::SingletonHolder< T >::registerSingletonMock | ( | CreateFunc | c, |
TeardownFunc | t | ||
) |
Definition at line 69 of file Singleton-inl.h.
References folly::gen::move, mutex_, folly::detail::singletonWarnRegisterMockEarlyAndAbort(), and type.
|
inlinestatic |
Definition at line 23 of file Singleton-inl.h.
References folly::detail::singletonWarnDoubleRegistrationAndAbort(), folly::T, and type.
|
inline |
Definition at line 120 of file Singleton-inl.h.
References UNLIKELY.
|
inline |
Definition at line 131 of file Singleton-inl.h.
References UNLIKELY.
|
inline |
Definition at line 142 of file Singleton-inl.h.
References UNLIKELY.
|
private |
Definition at line 362 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 343 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance(), and folly::detail::SingletonHolder< T >::creationStarted().
|
private |
Definition at line 360 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 349 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 351 of file Singleton.h.
|
private |
Definition at line 361 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 356 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 358 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 336 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 365 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().
|
private |
Definition at line 340 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance(), and folly::detail::SingletonHolder< T >::creationStarted().
|
private |
Definition at line 363 of file Singleton.h.
|
private |
Definition at line 333 of file Singleton.h.
Referenced by folly::detail::SingletonHolder< T >::createInstance().