Navigation
Unreal Engine C++ API Reference > Runtime > Core > Misc
Inheritance Hierarchy
- FLazySingleton
- TLazySingleton
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Misc/LazySingleton.h |
Include | #include "Misc/LazySingleton.h" |
Syntax
template<class T>
class TLazySingleton : public FLazySingleton
Remarks
Lazy singleton that can be torn down explicitly
Defining DISABLE_LAZY_SINGLETON_DESTRUCTION stops automatic static destruction and will instead leak singletons that have not been explicitly torn down. This helps prevent shutdown crashes and deadlocks in quick exit scenarios such as ExitProcess() on Windows.
T must be default constructible.
Example use case:
struct FOo { static FOo& Get(); static void TearDown();
// If default constructor is private friend class FLazySingleton; };
// Only include in .cpp and do not inline Get() and TearDown() #include "Misc/LazySingleton.h"
FOo& FOo::Get() { return TLazySingleton
void FOo::TearDown() { TLazySingleton
Constructors
No constructors are accessible with public or protected access.
Destructors
No destructors are accessible with public or protected access.