STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
shared_lock< _Mutex > Class Template Reference

Public Types

typedef _Mutex mutex_type
 

Public Member Functions

 shared_lock () _NOEXCEPT
 
 shared_lock (mutex_type &_Mtx)
 
 shared_lock (mutex_type &_Mtx, defer_lock_t) _NOEXCEPT
 
 shared_lock (mutex_type &_Mtx, try_to_lock_t)
 
 shared_lock (mutex_type &_Mtx, adopt_lock_t)
 
template<class _Rep , class _Period >
 shared_lock (mutex_type &_Mtx, const chrono::duration< _Rep, _Period > &_Rel_time)
 
template<class _Clock , class _Duration >
 shared_lock (mutex_type &_Mtx, const chrono::time_point< _Clock, _Duration > &_Abs_time)
 
 ~shared_lock () _NOEXCEPT
 
 shared_lock (shared_lock &&_Other) _NOEXCEPT
 
shared_lockoperator= (shared_lock &&_Right) _NOEXCEPT
 
 shared_lock (const shared_lock &)=delete
 
shared_lockoperator= (const shared_lock &)=delete
 
void lock ()
 
bool try_lock ()
 
template<class _Rep , class _Period >
bool try_lock_for (const chrono::duration< _Rep, _Period > &_Rel_time)
 
template<class _Clock , class _Duration >
bool try_lock_until (const chrono::time_point< _Clock, _Duration > &_Abs_time)
 
void unlock ()
 
void swap (shared_lock &_Right) _NOEXCEPT
 
mutex_typerelease () _NOEXCEPT
 
bool owns_lock () const _NOEXCEPT
 
 operator bool () const _NOEXCEPT
 
mutex_typemutex () const _NOEXCEPT
 

Private Member Functions

void _Validate () const
 

Private Attributes

_Mutex * _Pmtx
 
bool _Owns
 

Member Typedef Documentation

template<class _Mutex>
typedef _Mutex shared_lock< _Mutex >::mutex_type

Constructor & Destructor Documentation

template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( )
inline
262  : _Pmtx(0), _Owns(false)
263  { // default construct
264  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx)
inlineexplicit
267  : _Pmtx(&_Mtx), _Owns(true)
268  { // construct with mutex and lock shared
269  _Mtx.lock_shared();
270  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
defer_lock_t   
)
inline
273  : _Pmtx(&_Mtx), _Owns(false)
274  { // construct with unlocked mutex
275  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
try_to_lock_t   
)
inline
278  : _Pmtx(&_Mtx), _Owns(_Mtx.try_lock_shared())
279  { // construct with mutex and try to lock shared
280  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
adopt_lock_t   
)
inline
283  : _Pmtx(&_Mtx), _Owns(true)
284  { // construct with mutex and adopt ownership
285  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
template<class _Rep , class _Period >
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
const chrono::duration< _Rep, _Period > &  _Rel_time 
)
inline
291  : _Pmtx(&_Mtx), _Owns(_Mtx.try_lock_shared_for(_Rel_time))
292  { // construct with mutex and try to lock for relative time
293  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
template<class _Clock , class _Duration >
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
const chrono::time_point< _Clock, _Duration > &  _Abs_time 
)
inline
299  : _Pmtx(&_Mtx), _Owns(_Mtx.try_lock_shared_until(_Abs_time))
300  { // construct with mutex and try to lock until absolute time
301  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::~shared_lock ( )
inline
304  { // destroy the lock
305  if (_Owns)
306  _Pmtx->unlock_shared();
307  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( shared_lock< _Mutex > &&  _Other)
inline
310  : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns)
311  { // construct by moving _Other
312  _Other._Pmtx = 0;
313  _Other._Owns = false;
314  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( const shared_lock< _Mutex > &  )
delete

Member Function Documentation

template<class _Mutex>
void shared_lock< _Mutex >::_Validate ( ) const
inlineprivate
408  { // check if the mutex can be locked
409  if (!_Pmtx)
412  if (_Owns)
415  }
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:120
Definition: system_error:529
bool _Owns
Definition: shared_mutex:405
#define _THROW_NCEE(x, y)
Definition: xstddef:78
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
void shared_lock< _Mutex >::lock ( )
inline
331  { // lock the mutex
332  _Validate();
333  _Pmtx->lock_shared();
334  _Owns = true;
335  }
void _Validate() const
Definition: shared_mutex:407
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
mutex_type* shared_lock< _Mutex >::mutex ( ) const
inline
399  { // return pointer to managed mutex
400  return (_Pmtx);
401  }
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock< _Mutex >::operator bool ( ) const
inlineexplicit
394  { // return true if this object owns the lock
395  return (_Owns);
396  }
bool _Owns
Definition: shared_mutex:405
template<class _Mutex>
shared_lock& shared_lock< _Mutex >::operator= ( shared_lock< _Mutex > &&  _Right)
inline
317  { // copy by moving _Right
318  if (_Owns)
319  _Pmtx->unlock_shared();
320  _Pmtx = _Right._Pmtx;
321  _Owns = _Right._Owns;
322  _Right._Pmtx = 0;
323  _Right._Owns = false;
324  return (*this);
325  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
shared_lock& shared_lock< _Mutex >::operator= ( const shared_lock< _Mutex > &  )
delete
template<class _Mutex>
bool shared_lock< _Mutex >::owns_lock ( ) const
inline
389  { // return true if this object owns the lock
390  return (_Owns);
391  }
bool _Owns
Definition: shared_mutex:405
template<class _Mutex>
mutex_type* shared_lock< _Mutex >::release ( )
inline
380  { // release the mutex
381  _Mutex *_Res = _Pmtx;
382  _Pmtx = 0;
383  _Owns = false;
384  return (_Res);
385  }
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
void shared_lock< _Mutex >::swap ( shared_lock< _Mutex > &  _Right)
inline
374  { // swap with _Right
375  _STD swap(_Pmtx, _Right._Pmtx);
376  _STD swap(_Owns, _Right._Owns);
377  }
bool _Owns
Definition: shared_mutex:405
void swap(shared_lock &_Right) _NOEXCEPT
Definition: shared_mutex:373
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
bool shared_lock< _Mutex >::try_lock ( )
inline
338  { // try to lock the mutex
339  _Validate();
340  _Owns = _Pmtx->try_lock_shared();
341  return (_Owns);
342  }
void _Validate() const
Definition: shared_mutex:407
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
template<class _Rep , class _Period >
bool shared_lock< _Mutex >::try_lock_for ( const chrono::duration< _Rep, _Period > &  _Rel_time)
inline
347  { // try to lock the mutex for _Rel_time
348  _Validate();
349  _Owns = _Pmtx->try_lock_shared_for(_Rel_time);
350  return (_Owns);
351  }
void _Validate() const
Definition: shared_mutex:407
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
template<class _Clock , class _Duration >
bool shared_lock< _Mutex >::try_lock_until ( const chrono::time_point< _Clock, _Duration > &  _Abs_time)
inline
357  { // try to lock the mutex until _Abs_time
358  _Validate();
359  _Owns = _Pmtx->try_lock_shared_until(_Abs_time);
360  return (_Owns);
361  }
void _Validate() const
Definition: shared_mutex:407
bool _Owns
Definition: shared_mutex:405
_Mutex * _Pmtx
Definition: shared_mutex:404
template<class _Mutex>
void shared_lock< _Mutex >::unlock ( )
inline
364  { // try to unlock the mutex
365  if (!_Pmtx || !_Owns)
368  _Pmtx->unlock_shared();
369  _Owns = false;
370  }
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:120
Definition: system_error:529
bool _Owns
Definition: shared_mutex:405
#define _THROW_NCEE(x, y)
Definition: xstddef:78
_Mutex * _Pmtx
Definition: shared_mutex:404

Member Data Documentation

template<class _Mutex>
bool shared_lock< _Mutex >::_Owns
private
template<class _Mutex>
_Mutex* shared_lock< _Mutex >::_Pmtx
private

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