ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::TypeRef::Counted Class Reference

Heap base-class container for typeref objects. More...

#include <typeref.h>

Inheritance diagram for ucommon::TypeRef::Counted:
[legend]
Collaboration diagram for ucommon::TypeRef::Counted:
[legend]

Public Member Functions

bool is () const
 Is this object not empty? More...
 
unsigned copies () const
 Number of retains (smart pointers) referencing us. More...
 
TypeReleasegetRelease () const
 
void operator delete (void *address)
 Override delete to de-allocate actual heap. More...
 
void retain ()
 Retain a copy of this object. More...
 
void release ()
 Release a copy of this object. More...
 

Protected Member Functions

 Counted (void *address, size_t size, TypeRelease *ar=NULL)
 Construction of aligned container. More...
 
virtual void dealloc (void)
 Release memory and delete object when no longer referenced. More...
 

Protected Attributes

union {
   TypeRelease *   autorelease
 
   Counted *   linkrelease
 
}; 
 
Atomic::counter count
 
unsigned offset
 
size_t size
 

Private Member Functions

 __DELETE_COPY (Counted)
 

Friends

class TypeRef
 
class TypeRelease
 

Detailed Description

Heap base-class container for typeref objects.

This uses atomic reference counters for thread safety with maximal performance. This is used as a protected base class used for strongly typed heap containers through templates.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 86 of file typeref.h.

Constructor & Destructor Documentation

◆ Counted()

ucommon::TypeRef::Counted::Counted ( void *  address,
size_t  size,
TypeRelease ar = NULL 
)
explicitprotected

Construction of aligned container.

This is used to inform the object of the underlying real address it exists on the heap since malloc is not assured to be atomically aligned by default.

Parameters
addressof actual allocation.
sizeof object allocated.
arpool to use

Definition at line 27 of file typeref.cpp.

References ucommon::addr(), offset, and size.

Here is the call graph for this function:

Member Function Documentation

◆ __DELETE_COPY()

ucommon::TypeRef::Counted::__DELETE_COPY ( Counted  )
private

◆ copies()

unsigned ucommon::TypeRef::Counted::copies ( ) const
inline

Number of retains (smart pointers) referencing us.

Returns
number of copies of pointers referencing.

Definition at line 134 of file typeref.h.

References ucommon::Atomic::counter::get().

Referenced by ucommon::TypeRef::copies().

Here is the call graph for this function:

◆ dealloc()

void ucommon::TypeRef::Counted::dealloc ( void  )
protectedvirtual

Release memory and delete object when no longer referenced.

This gets called with the atomic reference counter < 1, such as when the last smart pointer de-references.

Reimplemented in ucommon::ArrayRef::Array, and ucommon::MapRef::Map.

Definition at line 35 of file typeref.cpp.

References ucommon::TypeRelease::dealloc().

Referenced by ucommon::TypeRelease::release().

Here is the call graph for this function:

◆ getRelease()

TypeRelease * ucommon::TypeRef::Counted::getRelease ( ) const
inline

Definition at line 138 of file typeref.h.

◆ is()

bool ucommon::TypeRef::Counted::is ( ) const
inline

Is this object not empty?

Returns
true if not empty.

Definition at line 126 of file typeref.h.

References ucommon::Atomic::counter::get().

Here is the call graph for this function:

◆ operator delete()

void ucommon::TypeRef::Counted::operator delete ( void *  address)

Override delete to de-allocate actual heap.

This is used because the object is atomically aligned, but the heap may not be.

Parameters
addressof our object.

Definition at line 49 of file typeref.cpp.

◆ release()

void ucommon::TypeRef::Counted::release ( void  )

Release a copy of this object.

Only when the reference count reaches 0 is it destroyed.

Definition at line 58 of file typeref.cpp.

Referenced by ucommon::ArrayRef::Array::assign(), ucommon::TypeRef::clear(), ucommon::MapRef::commit(), ucommon::ArrayRef::Array::dealloc(), ucommon::SharedRef::get(), ucommon::MapRef::release(), and ucommon::MapRef::update().

◆ retain()

Friends And Related Function Documentation

◆ TypeRef

friend class TypeRef
friend

Definition at line 92 of file typeref.h.

◆ TypeRelease

friend class TypeRelease
friend

Definition at line 93 of file typeref.h.

Member Data Documentation

◆ 

union { ... } ucommon::TypeRef::Counted::@28

◆ autorelease

TypeRelease* ucommon::TypeRef::Counted::autorelease

◆ count

Atomic::counter ucommon::TypeRef::Counted::count ( void  )
mutableprotected

Definition at line 100 of file typeref.h.

◆ linkrelease

Counted* ucommon::TypeRef::Counted::linkrelease

Definition at line 97 of file typeref.h.

Referenced by ucommon::TypeRelease::delist(), and ucommon::TypeRelease::enlist().

◆ offset

unsigned ucommon::TypeRef::Counted::offset
protected

Definition at line 101 of file typeref.h.

Referenced by Counted().

◆ size


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