Public Member Functions

CxUtils::Mutex::ScopedPtr< T > Class Template Reference

Template class for making a pointer to some data that that needs protection by a mutex. When the Ptr goes out of scope or is deleted the mutex is automatically released. More...

#include <mutex.h>

List of all members.

Public Member Functions

 ScopedPtr (T *data, const Mutex *mutex, const bool forceUnlock=false)
 Constructor for creation of a ScopedPtr.
virtual ~ScopedPtr ()
T * operator-> ()
const T * operator-> () const
T * Data ()
const T * Data () const
bool IsLocked () const
bool IsValid () const
bool operator== (const T *x) const
bool operator!= (const T *x) const

Detailed Description

template<class T>
class CxUtils::Mutex::ScopedPtr< T >

Template class for making a pointer to some data that that needs protection by a mutex. When the Ptr goes out of scope or is deleted the mutex is automatically released.

If the provided mutex is already locked, the scoped ptr will not double lock, and will also not perform an unlock on release. However, if on creation the forceUnlock flag is true, the pointer will always unlock regardless.

Definition at line 92 of file mutex.h.


Constructor & Destructor Documentation

template<class T>
CxUtils::Mutex::ScopedPtr< T >::ScopedPtr ( T *  data,
const Mutex mutex,
const bool  forceUnlock = false 
) [inline]

Constructor for creation of a ScopedPtr.

Parameters:
[in]dataPointer to data to be protected by a mutex until program exits the scope this structure was created in.
[in]mutexPointer to the mutex to use within the current program scope.
[in]forceUnlockIf true (default is false) then when the object goes out of scope, the mutex is unlocked always.

Definition at line 106 of file mutex.h.

template<class T>
virtual CxUtils::Mutex::ScopedPtr< T >::~ScopedPtr (  ) [inline, virtual]

Definition at line 127 of file mutex.h.


Member Function Documentation

template<class T>
T* CxUtils::Mutex::ScopedPtr< T >::Data (  ) [inline]

Definition at line 146 of file mutex.h.

template<class T>
const T* CxUtils::Mutex::ScopedPtr< T >::Data (  ) const [inline]

Definition at line 161 of file mutex.h.

template<class T>
bool CxUtils::Mutex::ScopedPtr< T >::IsLocked (  ) const [inline]

Definition at line 178 of file mutex.h.

template<class T>
bool CxUtils::Mutex::ScopedPtr< T >::IsValid (  ) const [inline]

Definition at line 187 of file mutex.h.

template<class T>
bool CxUtils::Mutex::ScopedPtr< T >::operator!= ( const T *  x ) const [inline]

Definition at line 199 of file mutex.h.

template<class T>
const T* CxUtils::Mutex::ScopedPtr< T >::operator-> (  ) const [inline]

Definition at line 145 of file mutex.h.

template<class T>
T* CxUtils::Mutex::ScopedPtr< T >::operator-> (  ) [inline]

Definition at line 144 of file mutex.h.

template<class T>
bool CxUtils::Mutex::ScopedPtr< T >::operator== ( const T *  x ) const [inline]

Definition at line 195 of file mutex.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines