Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::const_unique_lock_ptr< T, Lockable > Class Template Reference

unique_lock providing a const pointer access to the synchronized value type. More...

#include <synchronized_value.hpp>

Inheritance diagram for boost::const_unique_lock_ptr< T, Lockable >:
Collaboration diagram for boost::const_unique_lock_ptr< T, Lockable >:

Public Types

typedef T value_type
 
typedef Lockable mutex_type
 

Public Member Functions

 const_unique_lock_ptr (T const &val, Lockable &mtx)
 
 const_unique_lock_ptr (T const &val, Lockable &mtx, adopt_lock_t) BOOST_NOEXCEPT
 
 const_unique_lock_ptr (T const &val, Lockable &mtx, defer_lock_t) BOOST_NOEXCEPT
 
 const_unique_lock_ptr (T const &val, Lockable &mtx, try_to_lock_t) BOOST_NOEXCEPT
 
 const_unique_lock_ptr (BOOST_THREAD_RV_REF(const_unique_lock_ptr) other) BOOST_NOEXCEPT
 Move constructor. More...
 
 ~const_unique_lock_ptr ()
 If owns calls unlock() on the owned mutex. More...
 
const Toperator-> () const
 
const Toperator* () const
 
void swap (unique_lock &other) BOOST_NOEXCEPT
 
void lock ()
 
bool try_lock ()
 
void unlock ()
 
 operator bool () const BOOST_NOEXCEPT
 
bool owns_lock () const BOOST_NOEXCEPT
 
Lockablemutex () const BOOST_NOEXCEPT
 
Lockablerelease () BOOST_NOEXCEPT
 

Protected Attributes

T const & value_
 

Detailed Description

template<typename T, typename Lockable = mutex>
class boost::const_unique_lock_ptr< T, Lockable >

unique_lock providing a const pointer access to the synchronized value type.

An object of type const_unique_lock_ptr is a unique_lock that provides a const pointer access to the synchronized value type. As unique_lock controls the ownership of a lockable object within a scope. Ownership of the lockable object may be acquired at construction or after construction, and may be transferred, after acquisition, to another const_unique_lock_ptr object. Objects of type const_unique_lock_ptr are not copyable but are movable. The behavior of a program is undefined if the mutex and the value type pointed do not exist for the entire remaining lifetime of the const_unique_lock_ptr object. The supplied Mutex type shall meet the BasicLockable requirements.

Note
const_unique_lock_ptr<T, Lockable> meets the Lockable requirements. If Lockable meets the TimedLockable requirements, const_unique_lock_ptr<T,Lockable> also meets the TimedLockable requirements.
Parameters
Tthe value type.
Lockablethe mutex type protecting the value type.

Member Typedef Documentation

template<typename T , typename Lockable = mutex>
typedef Lockable boost::const_unique_lock_ptr< T, Lockable >::mutex_type
template<typename T , typename Lockable = mutex>
typedef T boost::const_unique_lock_ptr< T, Lockable >::value_type

Constructor & Destructor Documentation

template<typename T , typename Lockable = mutex>
boost::const_unique_lock_ptr< T, Lockable >::const_unique_lock_ptr ( T const &  val,
Lockable mtx 
)
inline
Parameters
valuereference of the value to protect.
mtxreference to the mutex used to protect the value.

If mutex_type is not a recursive mutex the calling thread does not own the mutex.

locks the mutex mtx, stores a reference to it and to the value type value.

template<typename T , typename Lockable = mutex>
boost::const_unique_lock_ptr< T, Lockable >::const_unique_lock_ptr ( T const &  val,
Lockable mtx,
adopt_lock_t   
)
inline
Parameters
valuereference of the value to protect.
mtxreference to the mutex used to protect the value.
tagof type adopt_lock_t used to differentiate the constructor. The calling thread own the mutex. stores a reference to it and to the value type value taking ownership.
template<typename T , typename Lockable = mutex>
boost::const_unique_lock_ptr< T, Lockable >::const_unique_lock_ptr ( T const &  val,
Lockable mtx,
defer_lock_t   
)
inline
Parameters
valuereference of the value to protect.
mtxreference to the mutex used to protect the value.
tagof type defer_lock_t used to differentiate the constructor. stores a reference to it and to the value type value c.
template<typename T , typename Lockable = mutex>
boost::const_unique_lock_ptr< T, Lockable >::const_unique_lock_ptr ( T const &  val,
Lockable mtx,
try_to_lock_t   
)
inline
Parameters
valuereference of the value to protect.
mtxreference to the mutex used to protect the value.
tagof type try_to_lock_t used to differentiate the constructor. If mutex_type is not a recursive mutex the calling thread does not own the mutex. try to lock the mutex mtx, stores a reference to it and to the value type value.
template<typename T , typename Lockable = mutex>
boost::const_unique_lock_ptr< T, Lockable >::const_unique_lock_ptr ( BOOST_THREAD_RV_REF(const_unique_lock_ptr< T, Lockable >)  other)
inline

Move constructor.

takes ownership of the mutex owned by other, stores a reference to the mutex and the value type of other.

template<typename T , typename Lockable = mutex>
boost::const_unique_lock_ptr< T, Lockable >::~const_unique_lock_ptr ( )
inline

If owns calls unlock() on the owned mutex.

Member Function Documentation

Lockable * boost::unique_lock< Lockable >::mutex ( ) const
inlineinherited
boost::unique_lock< Lockable >::operator bool ( ) const
inlineexplicitinherited
template<typename T , typename Lockable = mutex>
const T& boost::const_unique_lock_ptr< T, Lockable >::operator* ( ) const
inline
Returns
a constant reference to the protected value

References BOOST_ASSERT, boost::unique_lock< Lockable >::owns_lock(), and boost::const_unique_lock_ptr< T, Lockable >::value_.

template<typename T , typename Lockable = mutex>
const T* boost::const_unique_lock_ptr< T, Lockable >::operator-> ( ) const
inline
Returns
a constant pointer to the protected value

References BOOST_ASSERT, boost::unique_lock< Lockable >::owns_lock(), and boost::const_unique_lock_ptr< T, Lockable >::value_.

Lockable * boost::unique_lock< Lockable >::release ( )
inlineinherited
void boost::unique_lock< Lockable >::swap ( unique_lock< Lockable > &  other)
inlineinherited

Member Data Documentation


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