STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Private Attributes | List of all members
recursive_timed_mutex Class Reference

Public Member Functions

 recursive_timed_mutex () _NOEXCEPT
 
 recursive_timed_mutex (const recursive_timed_mutex &)=delete
 
recursive_timed_mutexoperator= (const recursive_timed_mutex &)=delete
 
void lock ()
 
bool try_lock () _NOEXCEPT
 
void unlock ()
 
template<class _Rep , class _Period >
bool try_lock_for (const chrono::duration< _Rep, _Period > &_Rel_time)
 
template<class _Time >
bool _Try_lock_until (_Time _Abs_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)
 

Private Attributes

mutex _My_mutex
 
condition_variable _My_cond
 
unsigned int _My_locked
 
thread::id _My_owner
 

Constructor & Destructor Documentation

recursive_timed_mutex::recursive_timed_mutex ( )
inline
763  : _My_locked(0)
764  { // default construct
765  }
unsigned int _My_locked
Definition: mutex:885
recursive_timed_mutex::recursive_timed_mutex ( const recursive_timed_mutex )
delete

Member Function Documentation

template<class _Time >
bool recursive_timed_mutex::_Try_lock_until ( _Time  _Abs_time)
inline
846  { // try to lock the mutex with timeout
848 
850 
851  if (_Tid == _My_owner)
852  {
853  if (_My_locked < UINT_MAX)
854  ++_My_locked;
855  else
856  return (false);
857  }
858  else
859  {
860  if (!_My_cond.wait_until(_Lock, _Abs_time,
861  [this] { return (_My_locked == 0); }))
862  return (false);
863  _My_locked = 1;
864  _My_owner = _Tid;
865  }
866  return (true);
867  }
condition_variable _My_cond
Definition: mutex:884
Definition: mutex:258
mutex _My_mutex
Definition: mutex:883
#define UINT_MAX
Definition: limits.h:36
thread::id _My_owner
Definition: mutex:886
unsigned int _My_locked
Definition: mutex:885
Definition: thread:149
_Cv_status wait_until(unique_lock< mutex > &_Lck, const chrono::time_point< _Clock, _Duration > &_Abs_time)
Definition: mutex:599
thread::id get_id() _NOEXCEPT
Definition: thread:204
void recursive_timed_mutex::lock ( )
inline
771  { // lock the mutex
773 
775 
776  if (_Tid == _My_owner)
777  {
778  if (_My_locked < UINT_MAX)
779  ++_My_locked;
780  else
783  }
784  else
785  {
786  while (_My_locked != 0)
787  _My_cond.wait(_Lock);
788  _My_locked = 1;
789  _My_owner = _Tid;
790  }
791  }
condition_variable _My_cond
Definition: mutex:884
Definition: mutex:258
mutex _My_mutex
Definition: mutex:883
error_code make_error_code(_Future_errc _Errno) _NOEXCEPT
Definition: future:120
Definition: system_error:529
#define UINT_MAX
Definition: limits.h:36
thread::id _My_owner
Definition: mutex:886
#define _THROW_NCEE(x, y)
Definition: xstddef:78
unsigned int _My_locked
Definition: mutex:885
void wait(unique_lock< mutex > &_Lck)
Definition: mutex:563
Definition: thread:149
thread::id get_id() _NOEXCEPT
Definition: thread:204
recursive_timed_mutex& recursive_timed_mutex::operator= ( const recursive_timed_mutex )
delete
bool recursive_timed_mutex::try_lock ( )
inline
794  { // try to lock the mutex
796 
798 
799  if (_Tid == _My_owner)
800  {
801  if (_My_locked < UINT_MAX)
802  ++_My_locked;
803  else
804  return (false);
805  }
806  else
807  {
808  if (_My_locked != 0)
809  return (false);
810  else
811  {
812  _My_locked = 1;
813  _My_owner = _Tid;
814  }
815  }
816  return (true);
817  }
mutex _My_mutex
Definition: mutex:883
#define UINT_MAX
Definition: limits.h:36
thread::id _My_owner
Definition: mutex:886
Definition: mutex:182
unsigned int _My_locked
Definition: mutex:885
Definition: thread:149
thread::id get_id() _NOEXCEPT
Definition: thread:204
template<class _Rep , class _Period >
bool recursive_timed_mutex::try_lock_for ( const chrono::duration< _Rep, _Period > &  _Rel_time)
inline
840  { // try to lock for duration
841  return (try_lock_until(chrono::steady_clock::now() + _Rel_time));
842  }
bool try_lock_until(const chrono::time_point< _Clock, _Duration > &_Abs_time)
Definition: mutex:871
static time_point now() _NOEXCEPT
Definition: chrono:997
template<class _Clock , class _Duration >
bool recursive_timed_mutex::try_lock_until ( const chrono::time_point< _Clock, _Duration > &  _Abs_time)
inline
873  { // try to lock the mutex with timeout
874  return (_Try_lock_until(_Abs_time));
875  }
bool _Try_lock_until(_Time _Abs_time)
Definition: mutex:845
bool recursive_timed_mutex::try_lock_until ( const xtime _Abs_time)
inline
878  { // try to lock the mutex with timeout
879  return (_Try_lock_until(_Abs_time));
880  }
bool _Try_lock_until(_Time _Abs_time)
Definition: mutex:845
void recursive_timed_mutex::unlock ( )
inline
820  { // unlock the mutex
821  bool _Do_notify = false;
822 
823  {
825  --_My_locked;
826  if (_My_locked == 0)
827  {
828  _Do_notify = true;
829  _My_owner = thread::id();
830  }
831  }
832 
833  if (_Do_notify)
835  }
void notify_one() _NOEXCEPT
Definition: mutex:553
condition_variable _My_cond
Definition: mutex:884
mutex _My_mutex
Definition: mutex:883
thread::id _My_owner
Definition: mutex:886
Definition: mutex:182
unsigned int _My_locked
Definition: mutex:885
Definition: thread:149

Member Data Documentation

condition_variable recursive_timed_mutex::_My_cond
private
unsigned int recursive_timed_mutex::_My_locked
private
mutex recursive_timed_mutex::_My_mutex
private
thread::id recursive_timed_mutex::_My_owner
private

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