2 #ifndef _MADARA_UTILITY_THREADSAFE_REFCOUNTER_H_
3 #define _MADARA_UTILITY_THREADSAFE_REFCOUNTER_H_
5 #include "ace/Guard_T.h"
6 #include "ace/Recursive_Thread_Mutex.h"
7 #include "madara/LockType.h"
33 bool increase_count =
false,
bool manage =
true);
70 const T *
get (void)
const;
89 Shim (T * t,
bool manage =
true);
This template class provides transparent reference counting of its template parameter T...
T * get_ptr(void)
get the underlying pointer
ThreadSafeRefcounter(void)
default Ctor
void operator=(T *ptr)
assignment operator for times when you don't want the reference increased for incoming ptr ...
T * operator->(void)
mimic pointer dereferencing
volatile int refcount_
Current value of the reference count.
void increment(void)
implementation of the increment operation
virtual ~ThreadSafeRefcounter(void)
Dtor will delete pointer if refcount becomes 0.
A shim class that keeps track of the reference count and a pointer to the type T that's reference cou...
T * t_
Pointer to the object that's being reference counted.
Shim * ptr_
Pointer to the Shim.
bool manage_
allow unmanaged references
Shim(T *t, bool manage=true)
Constructor.
T & operator*(void)
dereference operator
bool is_valid(void) const
checks to see if the underlying pointer is valid
MADARA_LOCK_TYPE mutex_
mutex for updating refcount_
void decrement(void)
implementation of the decrement operation