Honeycomb
0.1
Component-Model Framework
|
Reference-counted object for intrusive shared pointers. More...
#include <SharedPtr.h>
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 |
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.
|
inline |
Construct with allocator that is called to deallocate this shared object when all references have been released.
|
inlineprotected |
Destroys object. Called when strong reference count reaches 0. May be overridden to prevent destruction.
|
friend |