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 ()
 
unsigned int _Get_uses () const
 
void _Incref ()
 
void _Incwref ()
 
void _Decref ()
 
void _Decwref ()
 
long _Use_count () const
 
bool _Expired () const
 
virtual void_Get_deleter (const _XSTD2 type_info &) const
 

Protected Member Functions

 _Ref_count_base ()
 

Private Member Functions

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

Private Attributes

_Atomic_counter_t _Uses
 
_Atomic_counter_t _Weaks
 

Constructor & Destructor Documentation

_Ref_count_base::_Ref_count_base ( )
inlineprotected
60  { // construct
63  }
_Atomic_counter_t _Uses
Definition: memory:55
_Atomic_counter_t _Weaks
Definition: memory:56
#define _Init_atomic_counter(_Counter, _Value)
Definition: xatomic0.h:153
virtual _Ref_count_base::~_Ref_count_base ( )
inlinevirtual
67  { // ensure that derived classes can be destroyed properly
68  }

Member Function Documentation

void _Ref_count_base::_Decref ( )
inline
115  { // decrement use count
116  if (_MT_DECR(_Mtx, _Uses) == 0)
117  { // destroy managed resource, decrement weak reference count
118  _Destroy();
119  _Decwref();
120  }
121  }
#define _MT_DECR(mtx, x)
Definition: xmemory0:921
_Atomic_counter_t _Uses
Definition: memory:55
virtual void _Destroy()=0
void _Decwref()
Definition: memory:123
void _Ref_count_base::_Decwref ( )
inline
124  { // decrement weak reference count
125  if (_MT_DECR(_Mtx, _Weaks) == 0)
126  _Delete_this();
127  }
#define _MT_DECR(mtx, x)
Definition: xmemory0:921
_Atomic_counter_t _Weaks
Definition: memory:56
virtual void _Delete_this()=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
135  { // return true if _Uses == 0
136  return (_Get_uses() == 0);
137  }
unsigned int _Get_uses() const
Definition: memory:99
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 >.

140  { // return address of deleter object
141  return (0);
142  }
unsigned int _Ref_count_base::_Get_uses ( ) const
inline
100  { // return use count
101  return (_Get_atomic_count(_Uses));
102  }
_Atomic_counter_t _Uses
Definition: memory:55
#define _Get_atomic_count(_Counter)
Definition: xatomic0.h:151
void _Ref_count_base::_Incref ( )
inline
105  { // increment use count
106  _MT_INCR(_Mtx, _Uses);
107  }
_Atomic_counter_t _Uses
Definition: memory:55
#define _MT_INCR(mtx, x)
Definition: xmemory0:919
bool _Ref_count_base::_Incref_nz ( )
inline
71  { // increment use count if not zero, return true if successful
72  for (; ; )
73  { // loop until state is known
74  #if defined(_M_IX86) || defined(_M_X64) || defined(_M_CEE_PURE)
76  static_cast<volatile _Atomic_counter_t&>(_Uses);
77 
78  if (_Count == 0)
79  return (false);
80 
81  if (static_cast<_Atomic_integral_t>(_InterlockedCompareExchange(
82  reinterpret_cast<volatile long *>(&_Uses),
83  _Count + 1, _Count)) == _Count)
84  return (true);
85 
86  #else /* defined(_M_IX86) || defined(_M_X64) || defined(_M_CEE_PURE) */
87  _Atomic_integral_t _Count =
89 
90  if (_Count == 0)
91  return (false);
92 
94  return (true);
95  #endif /* defined(_M_IX86) || defined(_M_X64) || defined(_M_CEE_PURE) */
96  }
97  }
_Atomic_counter_t _Uses
Definition: memory:55
#define _Load_atomic_counter(_Counter)
Definition: xatomic0.h:171
#define _Compare_increment_atomic_counter(_Counter, _Expected)
Definition: xatomic0.h:178
_Uint4_t _Atomic_integral_t
Definition: xatomic0.h:29
_Diff _Count
Definition: algorithm:1941
long __cdecl _InterlockedCompareExchange(long volatile *, long, long)
_Atomic_integral_t _Atomic_counter_t
Definition: xatomic0.h:85
void _Ref_count_base::_Incwref ( )
inline
110  { // increment weak reference count
111  _MT_INCR(_Mtx, _Weaks);
112  }
_Atomic_counter_t _Weaks
Definition: memory:56
#define _MT_INCR(mtx, x)
Definition: xmemory0:919
long _Ref_count_base::_Use_count ( ) const
inline
130  { // return use count
131  return (_Get_uses());
132  }
unsigned int _Get_uses() const
Definition: memory:99

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: