Heap base-class container for typeref objects.
More...
#include <typeref.h>
|
| 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...
|
|
|
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.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 86 of file typeref.h.
◆ 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
-
address | of actual allocation. |
size | of object allocated. |
ar | pool to use |
◆ 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.
◆ dealloc()
virtual 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.
◆ 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.
◆ 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
-
◆ release()
void ucommon::TypeRef::Counted::release |
( |
| ) |
|
|
virtual |
Release a copy of this object.
Only when the reference count reaches 0 is it destroyed.
Implements ucommon::ObjectProtocol.
◆ retain()
void ucommon::TypeRef::Counted::retain |
( |
| ) |
|
|
virtual |
The documentation for this class was generated from the following file: