Used by the JUCE_DECLARE_SINGLETON macros to manage a static pointer to a singleton instance.
You generally won't use this directly, but see the macros JUCE_DECLARE_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL, and JUCE_IMPLEMENT_SINGLETON for how it is intended to be used.
Inherits MutexType.
Public Member Functions | |
SingletonHolder ()=default | |
~SingletonHolder () | |
Type * | get () |
Returns the current instance, or creates a new instance if there isn't one. | |
Type * | getWithoutChecking () |
Returns the current instance, or creates a new instance if there isn't one, but doesn't do any locking, or checking for recursion or error conditions. | |
void | deleteInstance () |
Deletes and resets the current instance, if there is one. | |
void | clear (Type *expectedObject) noexcept |
Called by the class's destructor to clear the pointer if it is currently set to the given object. |
Public Attributes | |
std::atomic< Type * > | instance { nullptr } |
|
default |
|
inline |
|
inline |
Returns the current instance, or creates a new instance if there isn't one.
References getWithoutChecking(), instance, and jassertfalse.
|
inline |
|
inline |
Deletes and resets the current instance, if there is one.
References instance.
|
inlinenoexcept |
Called by the class's destructor to clear the pointer if it is currently set to the given object.
References instance.
std::atomic<Type*> juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::instance { nullptr } |
Referenced by clear(), deleteInstance(), get(), getWithoutChecking(), and ~SingletonHolder().