YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ystdex::nifty_counter< _type > 模板类 参考

使用引用计数的静态初始化管理器。 更多...

#include <utility.hpp>

Public 类型

using object_type = _type
 

Public 成员函数

template<typename... _tParams>
 nifty_counter (_tParams &&...args)
 
 ~nifty_counter ()
 
static object_typeget ()
 
static size_t use_count ()
 
static size_t & get_count ()
 
static object_type *& get_object_ptr ()
 

详细描述

template<class _type>
class ystdex::nifty_counter< _type >

使用引用计数的静态初始化管理器。

前置条件
_type 满足 Destructible 。
注解
当实现支持静态 TLS 时为每线程单例,否则为全局静态单例。
警告
对于不支持 TLS 的实现非线程安全。
参见
ythread
http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Nifty_Counter
自从
build 425

静态初始化,通过引用计数保证所有在定义本类型的对象后已有静态对象被初始化。 在所有翻译单元的本类型对象析构后自动反初始化。

在文件 utility.hpp364 行定义.

成员类型定义说明

template<class _type >
using ystdex::nifty_counter< _type >::object_type = _type

在文件 utility.hpp367 行定义.

构造及析构函数说明

template<class _type >
template<typename... _tParams>
ystdex::nifty_counter< _type >::nifty_counter ( _tParams &&...  args)
inline
template<class _type >
ystdex::nifty_counter< _type >::~nifty_counter ( )
inline
自从
build 425
build 461

在文件 utility.hpp378 行定义.

成员函数说明

template<class _type >
static object_type& ystdex::nifty_counter< _type >::get ( )
inlinestatic

在文件 utility.hpp385 行定义.

参考 ystdex::nifty_counter< _type >::get_object_ptr() , 以及 yassume.

函数调用图:

template<class _type >
static size_t& ystdex::nifty_counter< _type >::get_count ( )
inlinestaticprivate

在文件 utility.hpp393 行定义.

参考 ythread.

参考自 ystdex::nifty_counter< _type >::nifty_counter() , 以及 ystdex::nifty_counter< _type >::use_count().

这是这个函数的调用关系图:

template<class _type >
static object_type*& ystdex::nifty_counter< _type >::get_object_ptr ( )
inlinestaticprivate

在文件 utility.hpp400 行定义.

参考 ythread.

参考自 ystdex::nifty_counter< _type >::get() , 以及 ystdex::nifty_counter< _type >::nifty_counter().

这是这个函数的调用关系图:

template<class _type >
static size_t ystdex::nifty_counter< _type >::use_count ( )
inlinestatic

在文件 utility.hpp409 行定义.

参考 ystdex::nifty_counter< _type >::get_count().

函数调用图:


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