Lunchbox  1.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lunchbox::Referenced Class Reference

Base class for referenced objects. More...

#include <referenced.h>

+ Inheritance diagram for lunchbox::Referenced:
+ Collaboration diagram for lunchbox::Referenced:

Public Member Functions

void ref (const void *holder LB_UNUSED=0) const
 Increase the reference count. More...
 
bool unref (const void *holder LB_UNUSED=0) const
 Decrease the reference count. More...
 
int32_t getRefCount () const
 
void printHolders (std::ostream &) const
 

Protected Member Functions

 Referenced ()
 Construct a new reference-counted object. More...
 
 Referenced (const Referenced &)
 Construct a new copy of a reference-counted object. More...
 
virtual ~Referenced ()
 Destruct a reference-counted object. More...
 
Referencedoperator= (const Referenced &)
 Assign another object to this object. More...
 
virtual LUNCHBOX_API void notifyFree ()
 

Detailed Description

Base class for referenced objects.

Implements reference-counted objects which destroy themselves once they are no longer referenced. Uses an Atomic variable to keep the reference count access thread-safe and efficient.

See Also
RefPtr

Definition at line 45 of file referenced.h.

Constructor & Destructor Documentation

lunchbox::Referenced::Referenced ( )
inlineprotected

Construct a new reference-counted object.

Version
1.0

Definition at line 126 of file referenced.h.

lunchbox::Referenced::Referenced ( const Referenced )
inlineprotected

Construct a new copy of a reference-counted object.

Version
1.0

Definition at line 132 of file referenced.h.

virtual lunchbox::Referenced::~Referenced ( )
inlineprotectedvirtual

Destruct a reference-counted object.

Version
1.0

Definition at line 141 of file referenced.h.

Member Function Documentation

int32_t lunchbox::Referenced::getRefCount ( ) const
inline
Returns
the current reference count.
Version
1.0

Definition at line 103 of file referenced.h.

Referenced& lunchbox::Referenced::operator= ( const Referenced )
inlineprotected

Assign another object to this object.

Version
1.1.3

Definition at line 151 of file referenced.h.

void lunchbox::Referenced::ref ( const void *holder  LB_UNUSED = 0) const
inline

Increase the reference count.

Version
1.0 .

Definition at line 49 of file referenced.h.

References lunchbox::backtrace(), lunchbox::Clock::getTime64(), and lunchbox::Log::instance().

+ Here is the call graph for this function:

bool lunchbox::Referenced::unref ( const void *holder  LB_UNUSED = 0) const
inline

Decrease the reference count.

The object is deleted when the reference count reaches 0.

Version
1.0
Returns
true if the reference count went to 0, false otherwise.

Definition at line 78 of file referenced.h.


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