StrongReferenceCounter Class Reference 内存

#include <atomictypes.h>

详细描述

Atomic reference counter.

Public Types

using  ValueType = UInt

公共成员函数

  StrongReferenceCounter ()
  StrongReferenceCounter (const StrongReferenceCounter &)
void  operator= (const StrongReferenceCounter &)
Bool   Inc ()
Bool   Dec ()
Bool   ConditionalInc ()
void  添加 ( UInt additionalReferences)
void  SetRelaxed ( UInt referenceCount)
  operator UInt () const
Bool   HasMultipleReferences () const

静态公共成员函数

static const StrongReferenceCounter NullValue ()
static StrongReferenceCounter Get (const void *object)

Protected Attributes

AtomicUInt   _value

Member Typedef Documentation

◆  ValueType

using ValueType = UInt

The underlying integral type of this reference counter.

构造函数 & 析构函数文档编制

◆  StrongReferenceCounter() [1/2]

StrongReferenceCounter ( )

◆  StrongReferenceCounter() [2/2]

StrongReferenceCounter ( const StrongReferenceCounter )

成员函数文档编制

◆  operator=()

void operator= ( const StrongReferenceCounter )

◆  Inc()

Bool Inc ( )

Increments reference counter (the caller acquires a strong reference).

返回
True for the very first reference, otherwise false.

◆  Dec()

Bool Dec ( )

Decrements reference counter (the caller removes a strong reference).

返回
True if no more strong references are held, otherwise false.

◆  ConditionalInc()

Bool ConditionalInc ( )

Adds a reference if the object is still strongly referenced.

返回
True if a strong reference was added, false if the object is currently being destructed.

◆  Add()

void Add ( UInt   additionalReferences )

Adds references.

参数
[in] additionalReferences The number of additional references to add.

◆  SetRelaxed()

void SetRelaxed ( UInt   referenceCount )

Sets a specifc reference count - for initialization only!

注意
You must guarantee that the access is exclusive and single-threaded. Use only for initialization of static objects which are not to destructed.

◆  operator UInt()

operator UInt ( ) const

Returns the number of strong references to the object.

返回
The number of strong references.

◆  HasMultipleReferences()

Bool HasMultipleReferences ( ) const

Returns whether an object has more than a single reference. For an object without a reference it will return false. For an object with one reference it will return false. For an object with a single reference and weak references it will return true. For an object with two references it will return true.

返回
True if the object has more than a single reference, false otherwise.

◆  NullValue()

static const StrongReferenceCounter & NullValue ( )
static

◆  Get()

static StrongReferenceCounter & Get ( const void *  object )
static

Returns the reference counter for classes which do not implement custom AddReference/RemoveReference methods.

Member Data Documentation

◆  _value

AtomicUInt _value
protected