Honeycomb  0.1
Component-Model Framework
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
honey::SharedObj< Subclass > Class Template Reference

Reference-counted object for intrusive shared pointers. More...

#include <SharedPtr.h>

Inheritance diagram for honey::SharedObj< Subclass >:
Inheritance graph
[legend]
Collaboration diagram for honey::SharedObj< Subclass >:
Collaboration graph
[legend]

Public Member Functions

template<class Alloc = std::allocator<Subclass>>
 SharedObj (Alloc &&a=Alloc()) debug_if(
 Construct with allocator that is called to deallocate this shared object when all references have been released. More...
 

Protected Member Functions

void finalize ()
 Destroys object. Called when strong reference count reaches 0. May be overridden to prevent destruction. More...
 

Friends

template<class , class , bool >
struct priv::SharedControlPtr
 
template<class >
class SharedPtr
 

Detailed Description

template<class Subclass>
class honey::SharedObj< Subclass >

Reference-counted object for intrusive shared pointers.

When possible, objects pointed to by SharedPtr should inherit from SharedObj, this is an intrusive pointer.
Intrusive pointers are safer than non-intrusive pointers as the shared ptr can be cast to a raw pointer and back again without issue.
The same operation with a non-intrusive pointer would result in each shared ptr holding a separate reference count, which will cause a crash.

A shared object will be destroyed when the last strong reference (SharedPtr) is released, but it will not be deallocated until the last weak reference (WeakPtr) is released.

A shared object does not have to be assigned to a shared ptr to be destroyed properly, it has a normal life cycle.

Constructor & Destructor Documentation

template<class Subclass>
template<class Alloc = std::allocator<Subclass>>
honey::SharedObj< Subclass >::SharedObj ( Alloc &&  a = Alloc())
inline

Construct with allocator that is called to deallocate this shared object when all references have been released.

Member Function Documentation

template<class Subclass>
void honey::SharedObj< Subclass >::finalize ( )
inlineprotected

Destroys object. Called when strong reference count reaches 0. May be overridden to prevent destruction.

Friends And Related Function Documentation

template<class Subclass>
template<class , class , bool >
friend struct priv::SharedControlPtr
friend
template<class Subclass>
template<class >
friend class SharedPtr
friend

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