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
263  : _Pmtx(0), _Owns(false)
264  { // default construct
265  }
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx)
inlineexplicit
268  : _Pmtx(_STD addressof(_Mtx)), _Owns(true)
269  { // construct with mutex and lock shared
270  _Mtx.lock_shared();
271  }
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
defer_lock_t   
)
inline
274  : _Pmtx(_STD addressof(_Mtx)), _Owns(false)
275  { // construct with unlocked mutex
276  }
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
try_to_lock_t   
)
inline
279  : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared())
280  { // construct with mutex and try to lock shared
281  }
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
adopt_lock_t   
)
inline
284  : _Pmtx(_STD addressof(_Mtx)), _Owns(true)
285  { // construct with mutex and adopt ownership
286  }
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
template<class _Rep , class _Period >
shared_lock< _Mutex >::shared_lock ( mutex_type _Mtx,
const chrono::duration< _Rep, _Period > &  _Rel_time 
)
inline
292  : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared_for(_Rel_time))
293  { // construct with mutex and try to lock for relative time
294  }
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
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
300  : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared_until(_Abs_time))
301  { // construct with mutex and try to lock until absolute time
302  }
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
shared_lock< _Mutex >::~shared_lock ( )
inline
305  { // destroy the lock
306  if (_Owns)
307  _Pmtx->unlock_shared();
308  }
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
shared_lock< _Mutex >::shared_lock ( shared_lock< _Mutex > &&  _Other)
inline
311  : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns)
312  { // construct by moving _Other
313  _Other._Pmtx = 0;
314  _Other._Owns = false;
315  }
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
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
409  { // check if the mutex can be locked
410  if (!_Pmtx)
413  if (_Owns)
416  }
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:119
Definition: system_error:526
bool _Owns
Definition: shared_mutex:406
#define _THROW_NCEE(x, y)
Definition: xstddef:51
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
void shared_lock< _Mutex >::lock ( )
inline
332  { // lock the mutex
333  _Validate();
334  _Pmtx->lock_shared();
335  _Owns = true;
336  }
void _Validate() const
Definition: shared_mutex:408
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
mutex_type* shared_lock< _Mutex >::mutex ( ) const
inline
400  { // return pointer to managed mutex
401  return (_Pmtx);
402  }
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
shared_lock< _Mutex >::operator bool ( ) const
inlineexplicit
395  { // return true if this object owns the lock
396  return (_Owns);
397  }
bool _Owns
Definition: shared_mutex:406
template<class _Mutex>
shared_lock& shared_lock< _Mutex >::operator= ( shared_lock< _Mutex > &&  _Right)
inline
318  { // copy by moving _Right
319  if (_Owns)
320  _Pmtx->unlock_shared();
321  _Pmtx = _Right._Pmtx;
322  _Owns = _Right._Owns;
323  _Right._Pmtx = 0;
324  _Right._Owns = false;
325  return (*this);
326  }
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
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
390  { // return true if this object owns the lock
391  return (_Owns);
392  }
bool _Owns
Definition: shared_mutex:406
template<class _Mutex>
mutex_type* shared_lock< _Mutex >::release ( )
inline
381  { // release the mutex
382  _Mutex *_Res = _Pmtx;
383  _Pmtx = 0;
384  _Owns = false;
385  return (_Res);
386  }
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
void shared_lock< _Mutex >::swap ( shared_lock< _Mutex > &  _Right)
inline
375  { // swap with _Right
376  _STD swap(_Pmtx, _Right._Pmtx);
377  _STD swap(_Owns, _Right._Owns);
378  }
bool _Owns
Definition: shared_mutex:406
void swap(shared_lock &_Right) _NOEXCEPT
Definition: shared_mutex:374
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
bool shared_lock< _Mutex >::try_lock ( )
inline
339  { // try to lock the mutex
340  _Validate();
341  _Owns = _Pmtx->try_lock_shared();
342  return (_Owns);
343  }
void _Validate() const
Definition: shared_mutex:408
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
template<class _Rep , class _Period >
bool shared_lock< _Mutex >::try_lock_for ( const chrono::duration< _Rep, _Period > &  _Rel_time)
inline
348  { // try to lock the mutex for _Rel_time
349  _Validate();
350  _Owns = _Pmtx->try_lock_shared_for(_Rel_time);
351  return (_Owns);
352  }
void _Validate() const
Definition: shared_mutex:408
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
template<class _Clock , class _Duration >
bool shared_lock< _Mutex >::try_lock_until ( const chrono::time_point< _Clock, _Duration > &  _Abs_time)
inline
358  { // try to lock the mutex until _Abs_time
359  _Validate();
360  _Owns = _Pmtx->try_lock_shared_until(_Abs_time);
361  return (_Owns);
362  }
void _Validate() const
Definition: shared_mutex:408
bool _Owns
Definition: shared_mutex:406
_Mutex * _Pmtx
Definition: shared_mutex:405
template<class _Mutex>
void shared_lock< _Mutex >::unlock ( )
inline
365  { // try to unlock the mutex
366  if (!_Pmtx || !_Owns)
369  _Pmtx->unlock_shared();
370  _Owns = false;
371  }
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:119
Definition: system_error:526
bool _Owns
Definition: shared_mutex:406
#define _THROW_NCEE(x, y)
Definition: xstddef:51
_Mutex * _Pmtx
Definition: shared_mutex:405

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: