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
condition_variable Class Reference

Public Types

typedef _Cnd_t native_handle_type
 

Public Member Functions

 condition_variable ()
 
 ~condition_variable () _NOEXCEPT
 
 condition_variable (const condition_variable &)=delete
 
condition_variableoperator= (const condition_variable &)=delete
 
void notify_one () _NOEXCEPT
 
void notify_all () _NOEXCEPT
 
void wait (unique_lock< mutex > &_Lck)
 
template<class _Predicate >
void wait (unique_lock< mutex > &_Lck, _Predicate _Pred)
 
template<class _Rep , class _Period >
_Cv_status wait_for (unique_lock< mutex > &_Lck, const chrono::duration< _Rep, _Period > &_Rel_time)
 
template<class _Rep , class _Period , class _Predicate >
bool wait_for (unique_lock< mutex > &_Lck, const chrono::duration< _Rep, _Period > &_Rel_time, _Predicate _Pred)
 
template<class _Clock , class _Duration >
_Cv_status wait_until (unique_lock< mutex > &_Lck, const chrono::time_point< _Clock, _Duration > &_Abs_time)
 
template<class _Clock , class _Duration , class _Predicate >
bool wait_until (unique_lock< mutex > &_Lck, const chrono::time_point< _Clock, _Duration > &_Abs_time, _Predicate _Pred)
 
_Cv_status wait_until (unique_lock< mutex > &_Lck, const xtime *_Abs_time)
 
template<class _Predicate >
bool wait_until (unique_lock< mutex > &_Lck, const xtime *_Abs_time, _Predicate _Pred)
 
template<class _Predicate >
bool _Wait_until1 (unique_lock< mutex > &_Lck, const xtime *_Abs_time, _Predicate &_Pred)
 
native_handle_type native_handle ()
 
void _Register (unique_lock< mutex > &_Lck, int *_Ready)
 
void _Unregister (mutex &_Mtx)
 

Private Member Functions

_Cnd_t _Mycnd () _NOEXCEPT
 

Private Attributes

aligned_storage< _Cnd_internal_imp_size, _Cnd_internal_imp_alignment >::type _Cnd_storage
 

Member Typedef Documentation

Constructor & Destructor Documentation

condition_variable::condition_variable ( )
inline
542  { // construct
544  }
_CRTIMP2_PURE void __cdecl _Cnd_init_in_situ(_Cnd_t)
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
condition_variable::~condition_variable ( )
inline
547  { // destroy
549  }
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
_CRTIMP2_PURE void __cdecl _Cnd_destroy_in_situ(_Cnd_t)
condition_variable::condition_variable ( const condition_variable )
delete

Member Function Documentation

_Cnd_t condition_variable::_Mycnd ( )
inlineprivate
680  { // get pointer to _Cnd_internal_imp_t inside _Cnd_storage
681  return (reinterpret_cast<_Cnd_t>(&_Cnd_storage));
682  }
aligned_storage< _Cnd_internal_imp_size, _Cnd_internal_imp_alignment >::type _Cnd_storage
Definition: mutex:677
void condition_variable::_Register ( unique_lock< mutex > &  _Lck,
int _Ready 
)
inline
665  { // register this object for release at thread exit
667  _Lck.release()->_Mymtx(), _Ready);
668  }
_CRTIMP2_PURE void __cdecl _Cnd_register_at_thread_exit(_Cnd_t, _Mtx_t, int *)
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
_Mutex * release() _NOEXCEPT
Definition: mutex:403
void condition_variable::_Unregister ( mutex _Mtx)
inline
671  { // unregister this object for release at thread exit
672  _Cnd_unregister_at_thread_exit(_Mtx._Mymtx());
673  }
_CRTIMP2_PURE void __cdecl _Cnd_unregister_at_thread_exit(_Mtx_t)
template<class _Predicate >
bool condition_variable::_Wait_until1 ( unique_lock< mutex > &  _Lck,
const xtime _Abs_time,
_Predicate &  _Pred 
)
inline
652  { // wait for signal with timeout and check predicate
653  while (!_Pred())
654  if (wait_until(_Lck, _Abs_time) == cv_status::timeout)
655  return (_Pred());
656  return (true);
657  }
_FwdIt const _Ty _Pr _Pred
Definition: algorithm:1985
_Cv_status wait_until(unique_lock< mutex > &_Lck, const chrono::time_point< _Clock, _Duration > &_Abs_time)
Definition: mutex:601
native_handle_type condition_variable::native_handle ( )
inline
660  { // return condition variable handle
661  return (_Mycnd());
662  }
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
void condition_variable::notify_all ( )
inline
560  { // wake up all waiters
562  }
int _Cnd_broadcastX(_Cnd_t _Cnd)
Definition: xthread:105
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
void condition_variable::notify_one ( )
inline
555  { // wake up one waiter
556  _Cnd_signalX(_Mycnd());
557  }
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
int _Cnd_signalX(_Cnd_t _Cnd)
Definition: xthread:110
condition_variable& condition_variable::operator= ( const condition_variable )
delete
void condition_variable::wait ( unique_lock< mutex > &  _Lck)
inline
565  { // wait for signal
566  // Nothing to do to comply with LWG 2135 because std::mutex lock/unlock are nothrow
567  _Cnd_waitX(_Mycnd(), _Lck.mutex()->_Mymtx());
568  }
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
_Mutex * mutex() const _NOEXCEPT
Definition: mutex:422
int _Cnd_waitX(_Cnd_t _Cnd, _Mtx_t _Mtx)
Definition: xthread:94
template<class _Predicate >
void condition_variable::wait ( unique_lock< mutex > &  _Lck,
_Predicate  _Pred 
)
inline
572  { // wait for signal and test predicate
573  while (!_Pred())
574  wait(_Lck);
575  }
_FwdIt const _Ty _Pr _Pred
Definition: algorithm:1985
void wait(unique_lock< mutex > &_Lck)
Definition: mutex:564
template<class _Rep , class _Period >
_Cv_status condition_variable::wait_for ( unique_lock< mutex > &  _Lck,
const chrono::duration< _Rep, _Period > &  _Rel_time 
)
inline
582  { // wait for duration
583  _STDEXT threads::xtime _Tgt = _To_xtime(_Rel_time);
584  return (wait_until(_Lck, &_Tgt));
585  }
xtime _To_xtime(const chrono::duration< _Rep, _Period > &_Rel_time)
Definition: chrono:1018
struct xtime xtime
#define _STDEXT
Definition: yvals.h:562
_Cv_status wait_until(unique_lock< mutex > &_Lck, const chrono::time_point< _Clock, _Duration > &_Abs_time)
Definition: mutex:601
template<class _Rep , class _Period , class _Predicate >
bool condition_variable::wait_for ( unique_lock< mutex > &  _Lck,
const chrono::duration< _Rep, _Period > &  _Rel_time,
_Predicate  _Pred 
)
inline
594  { // wait for signal with timeout and check predicate
595  _STDEXT threads::xtime _Tgt = _To_xtime(_Rel_time);
596  return (_Wait_until1(_Lck, &_Tgt, _Pred));
597  }
_FwdIt const _Ty _Pr _Pred
Definition: algorithm:1985
xtime _To_xtime(const chrono::duration< _Rep, _Period > &_Rel_time)
Definition: chrono:1018
struct xtime xtime
#define _STDEXT
Definition: yvals.h:562
bool _Wait_until1(unique_lock< mutex > &_Lck, const xtime *_Abs_time, _Predicate &_Pred)
Definition: mutex:648
template<class _Clock , class _Duration >
_Cv_status condition_variable::wait_until ( unique_lock< mutex > &  _Lck,
const chrono::time_point< _Clock, _Duration > &  _Abs_time 
)
inline
604  { // wait until time point
606  _Rel_time = _Abs_time - _Clock::now();
607  return (wait_for(_Lck, _Rel_time));
608  }
_Cv_status wait_for(unique_lock< mutex > &_Lck, const chrono::duration< _Rep, _Period > &_Rel_time)
Definition: mutex:579
_Duration duration
Definition: chrono:226
template<class _Clock , class _Duration , class _Predicate >
bool condition_variable::wait_until ( unique_lock< mutex > &  _Lck,
const chrono::time_point< _Clock, _Duration > &  _Abs_time,
_Predicate  _Pred 
)
inline
617  { // wait for signal with timeout and check predicate
619  _Rel_time = _Abs_time - _Clock::now();
620  _STDEXT threads::xtime _Tgt = _To_xtime(_Rel_time);
621  return (_Wait_until1(_Lck, &_Tgt, _Pred));
622  }
_FwdIt const _Ty _Pr _Pred
Definition: algorithm:1985
xtime _To_xtime(const chrono::duration< _Rep, _Period > &_Rel_time)
Definition: chrono:1018
struct xtime xtime
#define _STDEXT
Definition: yvals.h:562
bool _Wait_until1(unique_lock< mutex > &_Lck, const xtime *_Abs_time, _Predicate &_Pred)
Definition: mutex:648
_Duration duration
Definition: chrono:226
_Cv_status condition_variable::wait_until ( unique_lock< mutex > &  _Lck,
const xtime _Abs_time 
)
inline
627  { // wait for signal with timeout
628  if (!_Mtx_current_owns(_Lck.mutex()->_Mymtx()))
630 
631  // Nothing to do to comply with LWG 2135 because std::mutex lock/unlock are nothrow
632  int _Res = _Cnd_timedwaitX(_Mycnd(),
633  _Lck.mutex()->_Mymtx(), _Abs_time);
634  return (_Res == _Thrd_timedout
636  }
Definition: xthread:25
_Cnd_t _Mycnd() _NOEXCEPT
Definition: mutex:679
int _Cnd_timedwaitX(_Cnd_t _Cnd, _Mtx_t _Mtx, const xtime *_Xt)
Definition: xthread:99
_Mutex * mutex() const _NOEXCEPT
Definition: mutex:422
_CRTIMP2_PURE int __cdecl _Mtx_current_owns(_Mtx_t)
_CRTIMP2_PURE void __cdecl _Throw_Cpp_error(int _Code)
Definition: xthreads.h:20
template<class _Predicate >
bool condition_variable::wait_until ( unique_lock< mutex > &  _Lck,
const xtime _Abs_time,
_Predicate  _Pred 
)
inline
643  { // wait for signal with timeout and check predicate
644  return (_Wait_until1(_Lck, _Abs_time, _Pred));
645  }
_FwdIt const _Ty _Pr _Pred
Definition: algorithm:1985
bool _Wait_until1(unique_lock< mutex > &_Lck, const xtime *_Abs_time, _Predicate &_Pred)
Definition: mutex:648

Member Data Documentation

aligned_storage<_Cnd_internal_imp_size, _Cnd_internal_imp_alignment>::type condition_variable::_Cnd_storage
private

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