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
266  : _Pmtx(0), _Owns(false)
267  { // default construct
268  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx)
inlineexplicit
271  : _Pmtx(&_Mtx), _Owns(false)
272  { // construct and lock
273  _Pmtx->lock();
274  _Owns = true;
275  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
adopt_lock_t   
)
inline
278  : _Pmtx(&_Mtx), _Owns(true)
279  { // construct and assume already locked
280  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
defer_lock_t   
)
inline
283  : _Pmtx(&_Mtx), _Owns(false)
284  { // construct but don't lock
285  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
try_to_lock_t   
)
inline
288  : _Pmtx(&_Mtx), _Owns(_Pmtx->try_lock())
289  { // construct and try to lock
290  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
template<class _Rep , class _Period >
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
const chrono::duration< _Rep, _Period > &  _Rel_time 
)
inline
296  : _Pmtx(&_Mtx), _Owns(_Pmtx->try_lock_for(_Rel_time))
297  { // construct and lock with timeout
298  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
template<class _Clock , class _Duration >
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
const chrono::time_point< _Clock, _Duration > &  _Abs_time 
)
inline
304  : _Pmtx(&_Mtx), _Owns(_Pmtx->try_lock_until(_Abs_time))
305  { // construct and lock with timeout
306  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( _Mutex &  _Mtx,
const xtime _Abs_time 
)
inline
309  : _Pmtx(&_Mtx), _Owns(false)
310  { // try to lock until _Abs_time
311  _Owns = _Pmtx->try_lock_until(_Abs_time);
312  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::unique_lock ( unique_lock< _Mutex > &&  _Other)
inline
315  : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns)
316  { // destructive copy
317  _Other._Pmtx = 0;
318  _Other._Owns = false;
319  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock< _Mutex >::~unique_lock ( )
inline
336  { // clean up
337  if (_Owns)
338  _Pmtx->unlock();
339  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
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
431  { // check if the mutex can be locked
432  if (!_Pmtx)
435 
436  if (_Owns)
439  }
_Mutex * _Pmtx
Definition: mutex:427
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:120
Definition: system_error:529
#define _THROW_NCEE(x, y)
Definition: xstddef:78
bool _Owns
Definition: mutex:428
template<class _Mutex>
void unique_lock< _Mutex >::lock ( )
inline
346  { // lock the mutex
347  _Validate();
348  _Pmtx->lock();
349  _Owns = true;
350  }
_Mutex * _Pmtx
Definition: mutex:427
void _Validate() const
Definition: mutex:430
bool _Owns
Definition: mutex:428
template<class _Mutex>
_Mutex* unique_lock< _Mutex >::mutex ( ) const
inline
422  { // return pointer to managed mutex
423  return (_Pmtx);
424  }
_Mutex * _Pmtx
Definition: mutex:427
template<class _Mutex>
unique_lock< _Mutex >::operator bool ( ) const
inlineexplicit
417  { // return true if this object owns the lock
418  return (_Owns);
419  }
bool _Owns
Definition: mutex:428
template<class _Mutex>
unique_lock& unique_lock< _Mutex >::operator= ( unique_lock< _Mutex > &&  _Other)
inline
322  { // destructive copy
323  if (this != &_Other)
324  { // different, move contents
325  if (_Owns)
326  _Pmtx->unlock();
327  _Pmtx = _Other._Pmtx;
328  _Owns = _Other._Owns;
329  _Other._Pmtx = 0;
330  _Other._Owns = false;
331  }
332  return (*this);
333  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
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
412  { // return true if this object owns the lock
413  return (_Owns);
414  }
bool _Owns
Definition: mutex:428
template<class _Mutex>
_Mutex* unique_lock< _Mutex >::release ( )
inline
403  { // disconnect
404  _Mutex *_Res = _Pmtx;
405  _Pmtx = 0;
406  _Owns = false;
407  return (_Res);
408  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
template<class _Mutex>
void unique_lock< _Mutex >::swap ( unique_lock< _Mutex > &  _Other)
inline
397  { // swap with _Other
398  _STD swap(_Pmtx, _Other._Pmtx);
399  _STD swap(_Owns, _Other._Owns);
400  }
_Mutex * _Pmtx
Definition: mutex:427
bool _Owns
Definition: mutex:428
void swap(unique_lock &_Other) _NOEXCEPT
Definition: mutex:396
template<class _Mutex>
bool unique_lock< _Mutex >::try_lock ( )
inline
353  { // try to lock the mutex
354  _Validate();
355  _Owns = _Pmtx->try_lock();
356  return (_Owns);
357  }
_Mutex * _Pmtx
Definition: mutex:427
void _Validate() const
Definition: mutex:430
bool _Owns
Definition: mutex:428
template<class _Mutex>
template<class _Rep , class _Period >
bool unique_lock< _Mutex >::try_lock_for ( const chrono::duration< _Rep, _Period > &  _Rel_time)
inline
362  { // try to lock mutex for _Rel_time
363  _Validate();
364  _Owns = _Pmtx->try_lock_for(_Rel_time);
365  return (_Owns);
366  }
_Mutex * _Pmtx
Definition: mutex:427
void _Validate() const
Definition: mutex:430
bool _Owns
Definition: mutex:428
template<class _Mutex>
template<class _Clock , class _Duration >
bool unique_lock< _Mutex >::try_lock_until ( const chrono::time_point< _Clock, _Duration > &  _Abs_time)
inline
372  { // try to lock mutex until _Abs_time
373  _Validate();
374  _Owns = _Pmtx->try_lock_until(_Abs_time);
375  return (_Owns);
376  }
_Mutex * _Pmtx
Definition: mutex:427
void _Validate() const
Definition: mutex:430
bool _Owns
Definition: mutex:428
template<class _Mutex>
bool unique_lock< _Mutex >::try_lock_until ( const xtime _Abs_time)
inline
379  { // try to lock the mutex until _Abs_time
380  _Validate();
381  _Owns = _Pmtx->try_lock_until(_Abs_time);
382  return (_Owns);
383  }
_Mutex * _Pmtx
Definition: mutex:427
void _Validate() const
Definition: mutex:430
bool _Owns
Definition: mutex:428
template<class _Mutex>
void unique_lock< _Mutex >::unlock ( )
inline
386  { // try to unlock the mutex
387  if (!_Pmtx || !_Owns)
390 
391  _Pmtx->unlock();
392  _Owns = false;
393  }
_Mutex * _Pmtx
Definition: mutex:427
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:120
Definition: system_error:529
#define _THROW_NCEE(x, y)
Definition: xstddef:78
bool _Owns
Definition: mutex:428

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: