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
unique_lock< _Mutex > Class Template Reference

Public Types

typedef unique_lock< _Mutex > _Myt
 
typedef _Mutex mutex_type
 

Public Member Functions

 unique_lock () _NOEXCEPT
 
 unique_lock (_Mutex &_Mtx)
 
 unique_lock (_Mutex &_Mtx, adopt_lock_t)
 
 unique_lock (_Mutex &_Mtx, defer_lock_t) _NOEXCEPT
 
 unique_lock (_Mutex &_Mtx, try_to_lock_t)
 
template<class _Rep , class _Period >
 unique_lock (_Mutex &_Mtx, const chrono::duration< _Rep, _Period > &_Rel_time)
 
template<class _Clock , class _Duration >
 unique_lock (_Mutex &_Mtx, const chrono::time_point< _Clock, _Duration > &_Abs_time)
 
 unique_lock (_Mutex &_Mtx, const xtime *_Abs_time)
 
 unique_lock (unique_lock &&_Other) _NOEXCEPT
 
unique_lockoperator= (unique_lock &&_Other)
 
 ~unique_lock () _NOEXCEPT
 
 unique_lock (const unique_lock &)=delete
 
unique_lockoperator= (const unique_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)
 
bool try_lock_until (const xtime *_Abs_time)
 
void unlock ()
 
void swap (unique_lock &_Other) _NOEXCEPT
 
_Mutex * release () _NOEXCEPT
 
bool owns_lock () const _NOEXCEPT
 
 operator bool () const _NOEXCEPT
 
_Mutex * mutex () const _NOEXCEPT
 

Private Member Functions

void _Validate () const
 

Private Attributes

_Mutex * _Pmtx
 
bool _Owns
 

Member Typedef Documentation

template<class _Mutex>
typedef unique_lock<_Mutex> unique_lock< _Mutex >::_Myt
template<class _Mutex>
typedef _Mutex unique_lock< _Mutex >::mutex_type

Constructor & Destructor Documentation

template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( )
inline
267  : _Pmtx(0), _Owns(false)
268  { // default construct
269  }
_Mutex * _Pmtx
Definition: mutex:428
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx)
inlineexplicit
272  : _Pmtx(_STD addressof(_Mtx)), _Owns(false)
273  { // construct and lock
274  _Pmtx->lock();
275  _Owns = true;
276  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
adopt_lock_t   
)
inline
279  : _Pmtx(_STD addressof(_Mtx)), _Owns(true)
280  { // construct and assume already locked
281  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
defer_lock_t   
)
inline
284  : _Pmtx(_STD addressof(_Mtx)), _Owns(false)
285  { // construct but don't lock
286  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
try_to_lock_t   
)
inline
289  : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock())
290  { // construct and try to lock
291  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
template<class _Rep , class _Period >
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
const chrono::duration< _Rep, _Period > &  _Rel_time 
)
inline
297  : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock_for(_Rel_time))
298  { // construct and lock with timeout
299  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
template<class _Clock , class _Duration >
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
const chrono::time_point< _Clock, _Duration > &  _Abs_time 
)
inline
305  : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock_until(_Abs_time))
306  { // construct and lock with timeout
307  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
const xtime _Abs_time 
)
inline
310  : _Pmtx(_STD addressof(_Mtx)), _Owns(false)
311  { // try to lock until _Abs_time
312  _Owns = _Pmtx->try_lock_until(_Abs_time);
313  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( unique_lock< _Mutex > &&  _Other)
inline
316  : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns)
317  { // destructive copy
318  _Other._Pmtx = 0;
319  _Other._Owns = false;
320  }
_Mutex * _Pmtx
Definition: mutex:428
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::~unique_lock ( )
inline
337  { // clean up
338  if (_Owns)
339  _Pmtx->unlock();
340  }
_Mutex * _Pmtx
Definition: mutex:428
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( const unique_lock< _Mutex > &  )
delete

Member Function Documentation

template<class _Mutex>
void unique_lock< _Mutex >::_Validate ( ) const
inlineprivate
432  { // check if the mutex can be locked
433  if (!_Pmtx)
436 
437  if (_Owns)
440  }
_Mutex * _Pmtx
Definition: mutex:428
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:119
Definition: system_error:526
#define _THROW_NCEE(x, y)
Definition: xstddef:51
bool _Owns
Definition: mutex:429
template<class _Mutex>
void unique_lock< _Mutex >::lock ( )
inline
347  { // lock the mutex
348  _Validate();
349  _Pmtx->lock();
350  _Owns = true;
351  }
_Mutex * _Pmtx
Definition: mutex:428
void _Validate() const
Definition: mutex:431
bool _Owns
Definition: mutex:429
template<class _Mutex>
_Mutex* unique_lock< _Mutex >::mutex ( ) const
inline
423  { // return pointer to managed mutex
424  return (_Pmtx);
425  }
_Mutex * _Pmtx
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::operator bool ( ) const
inlineexplicit
418  { // return true if this object owns the lock
419  return (_Owns);
420  }
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock& unique_lock< _Mutex >::operator= ( unique_lock< _Mutex > &&  _Other)
inline
323  { // destructive copy
324  if (this != _STD addressof(_Other))
325  { // different, move contents
326  if (_Owns)
327  _Pmtx->unlock();
328  _Pmtx = _Other._Pmtx;
329  _Owns = _Other._Owns;
330  _Other._Pmtx = 0;
331  _Other._Owns = false;
332  }
333  return (*this);
334  }
_Mutex * _Pmtx
Definition: mutex:428
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
bool _Owns
Definition: mutex:429
template<class _Mutex>
unique_lock& unique_lock< _Mutex >::operator= ( const unique_lock< _Mutex > &  )
delete
template<class _Mutex>
bool unique_lock< _Mutex >::owns_lock ( ) const
inline
413  { // return true if this object owns the lock
414  return (_Owns);
415  }
bool _Owns
Definition: mutex:429
template<class _Mutex>
_Mutex* unique_lock< _Mutex >::release ( )
inline
404  { // disconnect
405  _Mutex *_Res = _Pmtx;
406  _Pmtx = 0;
407  _Owns = false;
408  return (_Res);
409  }
_Mutex * _Pmtx
Definition: mutex:428
bool _Owns
Definition: mutex:429
template<class _Mutex>
void unique_lock< _Mutex >::swap ( unique_lock< _Mutex > &  _Other)
inline
398  { // swap with _Other
399  _STD swap(_Pmtx, _Other._Pmtx);
400  _STD swap(_Owns, _Other._Owns);
401  }
_Mutex * _Pmtx
Definition: mutex:428
bool _Owns
Definition: mutex:429
void swap(unique_lock &_Other) _NOEXCEPT
Definition: mutex:397
template<class _Mutex>
bool unique_lock< _Mutex >::try_lock ( )
inline
354  { // try to lock the mutex
355  _Validate();
356  _Owns = _Pmtx->try_lock();
357  return (_Owns);
358  }
_Mutex * _Pmtx
Definition: mutex:428
void _Validate() const
Definition: mutex:431
bool _Owns
Definition: mutex:429
template<class _Mutex>
template<class _Rep , class _Period >
bool unique_lock< _Mutex >::try_lock_for ( const chrono::duration< _Rep, _Period > &  _Rel_time)
inline
363  { // try to lock mutex for _Rel_time
364  _Validate();
365  _Owns = _Pmtx->try_lock_for(_Rel_time);
366  return (_Owns);
367  }
_Mutex * _Pmtx
Definition: mutex:428
void _Validate() const
Definition: mutex:431
bool _Owns
Definition: mutex:429
template<class _Mutex>
template<class _Clock , class _Duration >
bool unique_lock< _Mutex >::try_lock_until ( const chrono::time_point< _Clock, _Duration > &  _Abs_time)
inline
373  { // try to lock mutex until _Abs_time
374  _Validate();
375  _Owns = _Pmtx->try_lock_until(_Abs_time);
376  return (_Owns);
377  }
_Mutex * _Pmtx
Definition: mutex:428
void _Validate() const
Definition: mutex:431
bool _Owns
Definition: mutex:429
template<class _Mutex>
bool unique_lock< _Mutex >::try_lock_until ( const xtime _Abs_time)
inline
380  { // try to lock the mutex until _Abs_time
381  _Validate();
382  _Owns = _Pmtx->try_lock_until(_Abs_time);
383  return (_Owns);
384  }
_Mutex * _Pmtx
Definition: mutex:428
void _Validate() const
Definition: mutex:431
bool _Owns
Definition: mutex:429
template<class _Mutex>
void unique_lock< _Mutex >::unlock ( )
inline
387  { // try to unlock the mutex
388  if (!_Pmtx || !_Owns)
391 
392  _Pmtx->unlock();
393  _Owns = false;
394  }
_Mutex * _Pmtx
Definition: mutex:428
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:119
Definition: system_error:526
#define _THROW_NCEE(x, y)
Definition: xstddef:51
bool _Owns
Definition: mutex:429

Member Data Documentation

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

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