STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
_Ref_count_base Class Referenceabstract
Inheritance diagram for _Ref_count_base:
_Ref_count< _Ty > _Ref_count_del< _Ty, _Dx > _Ref_count_del_alloc< _Ty, _Dx, _Alloc > _Ref_count_obj< _Ty > _Ref_count_obj_alloc< _Ty, _Alloc >

Public Member Functions

virtual ~_Ref_count_base () _NOEXCEPT
 
bool _Incref_nz ()
 
void _Incref ()
 
void _Incwref ()
 
void _Decref ()
 
void _Decwref ()
 
long _Use_count () const _NOEXCEPT
 
bool _Expired () const _NOEXCEPT
 
virtual void_Get_deleter (const _XSTD2 type_info &) const _NOEXCEPT
 

Protected Member Functions

 _Ref_count_base ()
 

Private Member Functions

virtual void _Destroy () _NOEXCEPT=0
 
virtual void _Delete_this () _NOEXCEPT=0
 

Private Attributes

_Atomic_counter_t _Uses
 
_Atomic_counter_t _Weaks
 

Constructor & Destructor Documentation

_Ref_count_base::_Ref_count_base ( )
inlineprotected
59  { // construct
62  }
_Atomic_counter_t _Uses
Definition: memory:54
_Atomic_counter_t _Weaks
Definition: memory:55
void _Init_atomic_counter(_Atomic_counter_t &_Counter, _Atomic_integral_t _Value)
Definition: xatomic0.h:60
virtual _Ref_count_base::~_Ref_count_base ( )
inlinevirtual
66  { // ensure that derived classes can be destroyed properly
67  }

Member Function Documentation

void _Ref_count_base::_Decref ( )
inline
109  { // decrement use count
110  if (_MT_DECR(_Uses) == 0)
111  { // destroy managed resource, decrement weak reference count
112  _Destroy();
113  _Decwref();
114  }
115  }
_Atomic_counter_t _Uses
Definition: memory:54
virtual void _Destroy() _NOEXCEPT=0
#define _MT_DECR(x)
Definition: xmemory0:1163
void _Decwref()
Definition: memory:117
void _Ref_count_base::_Decwref ( )
inline
118  { // decrement weak reference count
119  if (_MT_DECR(_Weaks) == 0)
120  _Delete_this();
121  }
_Atomic_counter_t _Weaks
Definition: memory:55
#define _MT_DECR(x)
Definition: xmemory0:1163
virtual void _Delete_this() _NOEXCEPT=0
virtual void _Ref_count_base::_Delete_this ( )
privatepure virtual
virtual void _Ref_count_base::_Destroy ( )
privatepure virtual
bool _Ref_count_base::_Expired ( ) const
inline
129  { // return true if _Uses == 0
130  return (_Use_count() == 0);
131  }
long _Use_count() const _NOEXCEPT
Definition: memory:123
virtual void* _Ref_count_base::_Get_deleter ( const _XSTD2 type_info ) const
inlinevirtual

Reimplemented in _Ref_count_del_alloc< _Ty, _Dx, _Alloc >, and _Ref_count_del< _Ty, _Dx >.

134  { // return address of deleter object
135  return (0);
136  }
void _Ref_count_base::_Incref ( )
inline
99  { // increment use count
100  _MT_INCR(_Uses);
101  }
_Atomic_counter_t _Uses
Definition: memory:54
#define _MT_INCR(x)
Definition: xmemory0:1161
bool _Ref_count_base::_Incref_nz ( )
inline
70  { // increment use count if not zero, return true if successful
71  for (; ; )
72  { // loop until state is known
73  #if _USE_INTERLOCKED_REFCOUNTING
75  static_cast<volatile _Atomic_counter_t&>(_Uses);
76 
77  if (_Count == 0)
78  return (false);
79 
80  if (static_cast<_Atomic_integral_t>(_InterlockedCompareExchange(
81  reinterpret_cast<volatile long *>(&_Uses),
82  _Count + 1, _Count)) == _Count)
83  return (true);
84 
85  #else /* _USE_INTERLOCKED_REFCOUNTING */
86  _Atomic_integral_t _Count =
88 
89  if (_Count == 0)
90  return (false);
91 
93  return (true);
94  #endif /* _USE_INTERLOCKED_REFCOUNTING */
95  }
96  }
_Atomic_counter_t _Uses
Definition: memory:54
unsigned int _Count
Definition: xcomplex:668
_Atomic_integral_t _Compare_increment_atomic_counter(_Atomic_counter_t &_Counter, _Atomic_integral_t _Expected)
Definition: xatomic.h:2538
_Uint4_t _Atomic_integral_t
Definition: xatomic0.h:25
_Atomic_integral_t _Load_atomic_counter(_Atomic_counter_t &_Counter)
Definition: xatomic.h:2523
long __cdecl _InterlockedCompareExchange(long volatile *, long, long)
_Atomic_integral_t _Atomic_counter_t
Definition: xatomic0.h:52
void _Ref_count_base::_Incwref ( )
inline
104  { // increment weak reference count
105  _MT_INCR(_Weaks);
106  }
#define _MT_INCR(x)
Definition: xmemory0:1161
_Atomic_counter_t _Weaks
Definition: memory:55
long _Ref_count_base::_Use_count ( ) const
inline
124  { // return use count
125  return (_Get_atomic_count(_Uses));
126  }
_Atomic_counter_t _Uses
Definition: memory:54
_Atomic_integral_t _Get_atomic_count(const _Atomic_counter_t &_Counter)
Definition: xatomic0.h:55

Member Data Documentation

_Atomic_counter_t _Ref_count_base::_Uses
private
_Atomic_counter_t _Ref_count_base::_Weaks
private

The documentation for this class was generated from the following file: