Ark Server API (ASA) - Wiki
|
#include <LazySingleton.h>
Static Public Member Functions | |
static T & | Get () |
static void | TearDown () |
static T * | TryGet () |
Private Member Functions | |
TLazySingleton (void(*Constructor)(void *)) | |
~TLazySingleton () | |
T * | TryGetValue () |
T & | GetValue () |
void | Reset () |
Static Private Member Functions | |
static TLazySingleton & | GetLazy (void(*Constructor)(void *)) |
Private Attributes | |
unsigned char | Data [sizeof(T)] |
T * | Ptr |
Additional Inherited Members | |
Static Protected Member Functions inherited from FLazySingleton | |
template<class T > | |
static void | Construct (void *Place) |
template<class T > | |
static void | Destruct (T *Instance) |
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<FOo>::Get(); }
void FOo::TearDown() { TLazySingleton<FOo>::TearDown(); }
Definition at line 50 of file LazySingleton.h.
|
inlineprivate |
Definition at line 85 of file LazySingleton.h.
|
inlineprivate |
Definition at line 96 of file LazySingleton.h.
Creates singleton once on first call. Thread-safe w.r.t. other Get() calls. Do not call after TearDown().
Definition at line 58 of file LazySingleton.h.
|
inlinestaticprivate |
Definition at line 76 of file LazySingleton.h.
|
inlineprivate |
Definition at line 107 of file LazySingleton.h.
|
inlineprivate |
Definition at line 113 of file LazySingleton.h.
Destroys singleton. No thread must access the singleton during or after this call.
Definition at line 64 of file LazySingleton.h.
Get or create singleton unless it's torn down
Definition at line 70 of file LazySingleton.h.
|
inlineprivate |
Definition at line 102 of file LazySingleton.h.
Definition at line 82 of file LazySingleton.h.
|
private |
Definition at line 83 of file LazySingleton.h.