libmoost
moost::guarded_ptr< T > Class Template Reference

Wrapper around shared_ptr that guards the referenced object with a mutex. More...

#include <guarded_ptr.hpp>

Inheritance diagram for moost::guarded_ptr< T >:
Collaboration diagram for moost::guarded_ptr< T >:

List of all members.

Classes

class  exclusive_access
 Objects of this class represent an exclusive lock of the guarded_ptr's mutex. More...
class  shared_access
 Objects of this class represent a shared lock of the guarded_ptr's mutex. More...
class  upgradable_access
 Objects of this class represent an upgradable lock of the guarded_ptr's mutex. More...

Public Types

typedef T element_type
typedef T value_type
typedef T * pointer
typedef T const * const_pointer
typedef T & reference
typedef T const & const_reference

Public Member Functions

 guarded_ptr (pointer ptr)

Private Member Functions

pointer assert_not_null (pointer ptr)

Private Attributes

boost::scoped_ptr
< element_type > const 
m_ptr
boost::shared_mutex m_mutex

Detailed Description

template<typename T>
class moost::guarded_ptr< T >

Wrapper around shared_ptr that guards the referenced object with a mutex.

Objects of this template class are constructed from a shared pointer. A guarded_ptr keeps a copy of the shared_ptr and allows construction of scoped shared_access, exclusive_access and upgradable_access objects that acquire the corresponding type of lock for the guarded_ptr's internal mutex and implement operator* and operator-> to reference the object the original shared_ptr refers to.

Definition at line 120 of file guarded_ptr.hpp.


Member Typedef Documentation

template<typename T>
typedef T const* moost::guarded_ptr< T >::const_pointer

Definition at line 126 of file guarded_ptr.hpp.

template<typename T>
typedef T const& moost::guarded_ptr< T >::const_reference

Definition at line 128 of file guarded_ptr.hpp.

template<typename T>
typedef T moost::guarded_ptr< T >::element_type

Definition at line 123 of file guarded_ptr.hpp.

template<typename T>
typedef T* moost::guarded_ptr< T >::pointer

Definition at line 125 of file guarded_ptr.hpp.

template<typename T>
typedef T& moost::guarded_ptr< T >::reference

Definition at line 127 of file guarded_ptr.hpp.

template<typename T>
typedef T moost::guarded_ptr< T >::value_type

Definition at line 124 of file guarded_ptr.hpp.


Constructor & Destructor Documentation

template<typename T>
moost::guarded_ptr< T >::guarded_ptr ( pointer  ptr) [inline]

Definition at line 295 of file guarded_ptr.hpp.


Member Function Documentation

template<typename T>
pointer moost::guarded_ptr< T >::assert_not_null ( pointer  ptr) [inline, private]

Definition at line 301 of file guarded_ptr.hpp.


Member Data Documentation

template<typename T>
boost::shared_mutex moost::guarded_ptr< T >::m_mutex [mutable, private]

Definition at line 308 of file guarded_ptr.hpp.

template<typename T>
boost::scoped_ptr<element_type> const moost::guarded_ptr< T >::m_ptr [private]

Definition at line 307 of file guarded_ptr.hpp.


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