cartobase 6.0.6
carto::MutexRcPtr< T > Class Template Reference

Mutex-protected rc_ptr. More...

#include <cartobase/smart/mutexrcptr.h>

Public Member Functions

 MutexRcPtr ()
 
 MutexRcPtr (T *ptr)
 
 MutexRcPtr (MutexRcPtr< T > &ptr)
 
 ~MutexRcPtr ()
 
void reset (T *p=0)
 
T * get ()
 
const T * get () const
 
T * release ()
 
MutexRcPtr< T > & operator= (MutexRcPtr< T > &other)
 
T * operator-> ()
 
const T * operator-> () const
 
T & operator* ()
 
const T & operator* () const
 
bool operator< (const MutexRcPtr< T > &other) const
 
bool operator== (const MutexRcPtr< T > &other) const
 
bool operator!= (const MutexRcPtr< T > &other) const
 
int refCount () const
 
rc_ptr< T > rcptr ()
 not thread-safe, almost private, for low-level operation only
 
MutexedObject::Mutexmutex ()
 
void lock ()
 
void unlock ()
 

Detailed Description

template<typename T>
class carto::MutexRcPtr< T >

Mutex-protected rc_ptr.

This class is a "temporary" solution to have thread-safe rc_ptr. In the future version, the normal rc_ptr class should be thread-safe using atomic operations.

Here we are using a mutex to access the pointer and ref-counter. The API is willingly not related to the rc_ptr API (no inheritance)

Definition at line 83 of file mutexrcptr.h.

Constructor & Destructor Documentation

◆ MutexRcPtr() [1/3]

template<typename T>
carto::MutexRcPtr< T >::MutexRcPtr ( )
inline

Definition at line 150 of file mutexrcptr.h.

Referenced by MutexRcPtr(), operator!=(), operator<(), operator=(), and operator==().

◆ MutexRcPtr() [2/3]

template<typename T>
carto::MutexRcPtr< T >::MutexRcPtr ( T * ptr)
inline

Definition at line 156 of file mutexrcptr.h.

◆ MutexRcPtr() [3/3]

template<typename T>
carto::MutexRcPtr< T >::MutexRcPtr ( MutexRcPtr< T > & ptr)
inline

Definition at line 168 of file mutexrcptr.h.

References lock(), MutexRcPtr(), and unlock().

◆ ~MutexRcPtr()

template<typename T>
carto::MutexRcPtr< T >::~MutexRcPtr ( )
inline

Definition at line 177 of file mutexrcptr.h.

References reset().

Member Function Documentation

◆ get() [1/2]

template<typename T>
T * carto::MutexRcPtr< T >::get ( )
inline

◆ get() [2/2]

template<typename T>
const T * carto::MutexRcPtr< T >::get ( ) const
inline

Definition at line 224 of file mutexrcptr.h.

◆ lock()

template<typename T>
void carto::MutexRcPtr< T >::lock ( )
inline

Definition at line 332 of file mutexrcptr.h.

References carto::Mutex::lock(), and mutex().

Referenced by MutexRcPtr(), operator=(), refCount(), release(), and reset().

◆ mutex()

template<typename T>
MutexedObject::Mutex * carto::MutexRcPtr< T >::mutex ( )
inline

Definition at line 324 of file mutexrcptr.h.

Referenced by lock(), and unlock().

◆ operator!=()

template<typename T>
bool carto::MutexRcPtr< T >::operator!= ( const MutexRcPtr< T > & other) const
inline

Definition at line 300 of file mutexrcptr.h.

References get(), and MutexRcPtr().

◆ operator*() [1/2]

template<typename T>
T & carto::MutexRcPtr< T >::operator* ( )
inline

Definition at line 272 of file mutexrcptr.h.

References get().

◆ operator*() [2/2]

template<typename T>
const T & carto::MutexRcPtr< T >::operator* ( ) const
inline

Definition at line 279 of file mutexrcptr.h.

References get().

◆ operator->() [1/2]

template<typename T>
T * carto::MutexRcPtr< T >::operator-> ( )
inline

Definition at line 258 of file mutexrcptr.h.

References get().

◆ operator->() [2/2]

template<typename T>
const T * carto::MutexRcPtr< T >::operator-> ( ) const
inline

Definition at line 265 of file mutexrcptr.h.

References get().

◆ operator<()

template<typename T>
bool carto::MutexRcPtr< T >::operator< ( const MutexRcPtr< T > & other) const
inline

Definition at line 286 of file mutexrcptr.h.

References get(), and MutexRcPtr().

◆ operator=()

template<typename T>
MutexRcPtr< T > & carto::MutexRcPtr< T >::operator= ( MutexRcPtr< T > & other)
inline

Definition at line 246 of file mutexrcptr.h.

References lock(), MutexRcPtr(), reset(), and unlock().

◆ operator==()

template<typename T>
bool carto::MutexRcPtr< T >::operator== ( const MutexRcPtr< T > & other) const
inline

Definition at line 293 of file mutexrcptr.h.

References get(), and MutexRcPtr().

◆ rcptr()

template<typename T>
rc_ptr< T > carto::MutexRcPtr< T >::rcptr ( )
inline

not thread-safe, almost private, for low-level operation only

Definition at line 317 of file mutexrcptr.h.

◆ refCount()

template<typename T>
int carto::MutexRcPtr< T >::refCount ( ) const
inline

Definition at line 307 of file mutexrcptr.h.

References lock(), and unlock().

◆ release()

template<typename T>
T * carto::MutexRcPtr< T >::release ( )
inline

Definition at line 235 of file mutexrcptr.h.

References lock().

◆ reset()

template<typename T>
void carto::MutexRcPtr< T >::reset ( T * p = 0)
inline

Definition at line 184 of file mutexrcptr.h.

References lock().

Referenced by operator=(), and ~MutexRcPtr().

◆ unlock()

template<typename T>
void carto::MutexRcPtr< T >::unlock ( )
inline

Definition at line 341 of file mutexrcptr.h.

References mutex(), and carto::Mutex::unlock().

Referenced by MutexRcPtr(), operator=(), and refCount().


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