Skip to content

Commit 27f318a

Browse files
committed
merge _Wait_until_sys_time and add TRANSITION comment.
1 parent 8ecbc2a commit 27f318a

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

stl/inc/mutex

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -588,16 +588,21 @@ public:
588588
#if _HAS_CXX20
589589
static_assert(chrono::is_clock_v<_Clock>, "Clock type required");
590590
#endif // _HAS_CXX20
591+
if (!_Mtx_current_owns(_Lck.mutex()->_Mymtx())) {
592+
_Throw_Cpp_error(_OPERATION_NOT_PERMITTED);
593+
}
591594
for (;;) {
592595
const auto _Now = _Clock::now();
593596
if (_Abs_time <= _Now) {
594597
return cv_status::timeout;
595598
}
596599

600+
// TRANSITION, ABI: incorrectly relying on system_clock
597601
_timespec64 _Tgt;
598602
(void) _To_timespec64_sys_10_day_clamped(_Tgt, _Abs_time - _Now);
599-
const cv_status _Result = _Wait_until_sys_time(_Lck, &_Tgt);
600-
if (_Result == cv_status::no_timeout) {
603+
// Nothing to do to comply with LWG-2135 because std::mutex lock/unlock are nothrow
604+
const _Thrd_result _Res = _Cnd_timedwait(_Mycnd(), _Lck.mutex()->_Mymtx(), _Abs_time);
605+
if (_Res == _Thrd_result::_Success) {
601606
return cv_status::no_timeout;
602607
}
603608
}
@@ -635,22 +640,6 @@ private:
635640
_Cnd_t _Mycnd() noexcept { // get pointer to _Cnd_internal_imp_t inside _Cnd_storage
636641
return reinterpret_cast<_Cnd_t>(&_Cnd_storage);
637642
}
638-
639-
cv_status _Wait_until_sys_time(unique_lock<mutex>& _Lck, const _timespec64* _Abs_time) {
640-
// wait for signal with timeout
641-
if (!_Mtx_current_owns(_Lck.mutex()->_Mymtx())) {
642-
_Throw_Cpp_error(_OPERATION_NOT_PERMITTED);
643-
}
644-
645-
// Nothing to do to comply with LWG-2135 because std::mutex lock/unlock are nothrow
646-
const _Thrd_result _Res = _Cnd_timedwait(_Mycnd(), _Lck.mutex()->_Mymtx(), _Abs_time);
647-
648-
if (_Res == _Thrd_result::_Success) {
649-
return cv_status::no_timeout;
650-
} else {
651-
return cv_status::timeout;
652-
}
653-
}
654643
};
655644

656645
struct _UInt_is_zero {

0 commit comments

Comments
 (0)