engine
 
载入中...
搜索中...
未找到
静态 Public 成员函数 | 所有成员列表
TLazySingleton< T > 模板类 参考final

Lazy singleton that can be torn down explicitly 更多...

#include <LazySingleton.h>

+ 类 TLazySingleton< T > 继承关系图:

静态 Public 成员函数

static T & Get ()
 Creates singleton once on first call. 更多...
 
static void TearDown ()
 Destroys singleton. 更多...
 
static T * TryGet ()
 Get or create singleton unless it's torn down
 

详细描述

template<class T>
class TLazySingleton< T >

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(); }

成员函数说明

◆ Get()

template<class T >
static T & TLazySingleton< T >::Get ( )
inlinestatic

Creates singleton once on first call.

Thread-safe w.r.t. other Get() calls. Do not call after TearDown().

◆ TearDown()

template<class T >
static void TLazySingleton< T >::TearDown ( )
inlinestatic

Destroys singleton.

No thread must access the singleton during or after this call.


该类的文档由以下文件生成: