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..
![]() ![]() |
Heap base-class container for typeref objects. More...
#include <typeref.h>
Public Member Functions | |
bool | is () const |
Is this object not empty? More... | |
unsigned | copies () const |
Number of retains (smart pointers) referencing us. More... | |
TypeRelease * | getRelease () 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 |
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.
|
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.
address | of actual allocation. |
size | of object allocated. |
ar | pool to use |
Definition at line 27 of file typeref.cpp.
References ucommon::addr(), offset, and size.
|
private |
|
inline |
Number of retains (smart pointers) referencing us.
Definition at line 134 of file typeref.h.
References ucommon::Atomic::counter::get().
Referenced by ucommon::TypeRef::copies().
|
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().
|
inline |
|
inline |
Is this object not empty?
Definition at line 126 of file typeref.h.
References ucommon::Atomic::counter::get().
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.
address | of our object. |
Definition at line 49 of file typeref.cpp.
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().
void ucommon::TypeRef::Counted::retain | ( | void | ) |
Retain a copy of this object.
Usually a smart pointer referencing.
Definition at line 53 of file typeref.cpp.
Referenced by ucommon::MapRef::access(), ucommon::MapRef::add(), ucommon::MapRef::append(), ucommon::TypeRef::assign(), ucommon::MapRef::Instance::assign(), ucommon::SharedRef::get(), ucommon::MapRef::Instance::Instance(), ucommon::MapRef::modify(), ucommon::TypeRef::set(), ucommon::TypeRef::TypeRef(), and ucommon::MapRef::update().
|
friend |
union { ... } ucommon::TypeRef::Counted::@28 |
TypeRelease* ucommon::TypeRef::Counted::autorelease |
Definition at line 96 of file typeref.h.
Referenced by ucommon::TypeRelease::delist(), ucommon::TypeRef::is_released(), and ucommon::TypeRelease::release().
|
mutableprotected |
Counted* ucommon::TypeRef::Counted::linkrelease |
Definition at line 97 of file typeref.h.
Referenced by ucommon::TypeRelease::delist(), and ucommon::TypeRelease::enlist().
|
protected |
|
protected |
Definition at line 102 of file typeref.h.
Referenced by ucommon::MapRef::access(), ucommon::MapRef::add(), ucommon::MapRef::append(), ucommon::ArrayRef::Array::Array(), ucommon::ArrayRef::ArrayRef(), ucommon::ArrayRef::assign(), ucommon::MapRef::commit(), Counted(), ucommon::ArrayRef::get(), ucommon::MapRef::modify(), ucommon::ArrayRef::pop(), ucommon::ArrayRef::pull(), ucommon::ArrayRef::push(), ucommon::MapRef::release(), ucommon::ArrayRef::reset(), ucommon::TypeRelease::size(), and ucommon::TypeRef::size().