This class implements intrusive reference counting to use derived classes in a boost::intrusive_ptr
.
More...
#include <ref_counted.hpp>
Public Member Functions | |
long | ref_count () |
Static Public Member Functions | |
static void | add_ref (ref_counted *rc) |
static void | release (ref_counted *rc) |
Protected Member Functions | |
ref_counted () | |
void | ref () |
bool | deref () |
This class implements intrusive reference counting to use derived classes in a boost::intrusive_ptr
.
hamcast::ref_counted::ref_counted | ( | ) | [protected] |
Initializes the reference count with 0.
static void hamcast::ref_counted::add_ref | ( | ref_counted * | rc | ) | [static] |
Convenience function that increments the reference count of rc
.
Equal to if (rc) rc->ref();
rc | A native pointer to a reference counted object. |
bool hamcast::ref_counted::deref | ( | ) | [protected] |
Atomically decrement the reference count.
void hamcast::ref_counted::ref | ( | ) | [protected] |
Atomically increment the reference count.
long hamcast::ref_counted::ref_count | ( | ) |
Get the current reference count.
static void hamcast::ref_counted::release | ( | ref_counted * | rc | ) | [static] |
Convenience function that decrements the reference count of rc
and deletes rc
if needed.
Equal to if (rc && !rc->deref()) delete rc;
rc | A native pointer to a reference counted object. |