diff --git a/stl/inc/mutex b/stl/inc/mutex index 68d7cb6d58..df95413a25 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -762,18 +762,6 @@ private: } } - template - bool _Wait_until1(unique_lock& _Lck, const _timespec64* _Abs_time, _Predicate& _Pred) { - // wait for signal with timeout and check predicate - while (!_Pred()) { - if (_Wait_until_sys_time(_Lck, _Abs_time) == cv_status::timeout) { - return _Pred(); - } - } - - return true; - } - template bool _Wait_until1( unique_lock& _Lck, const chrono::time_point<_Clock, _Duration>& _Abs_time, _Predicate& _Pred) { @@ -843,8 +831,12 @@ public: return try_lock_until(_To_absolute_time(_Rel_time)); } - template - bool _Try_lock_until(_Time _Abs_time) { // try to lock the mutex with timeout + template + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + // try to lock the mutex with timeout +#if _HAS_CXX20 + static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); +#endif // _HAS_CXX20 unique_lock _Lock(_My_mutex); if (!_My_cond.wait_until(_Lock, _Abs_time, _UInt_is_zero{_My_locked})) { return false; @@ -854,15 +846,6 @@ public: return true; } - template - _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { - // try to lock the mutex with timeout -#if _HAS_CXX20 - static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); -#endif // _HAS_CXX20 - return _Try_lock_until(_Abs_time); - } - private: mutex _My_mutex; condition_variable _My_cond; @@ -944,8 +927,12 @@ public: return try_lock_until(_To_absolute_time(_Rel_time)); } - template - bool _Try_lock_until(_Time _Abs_time) { // try to lock the mutex with timeout + template + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + // try to lock the mutex with timeout +#if _HAS_CXX20 + static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); +#endif // _HAS_CXX20 const thread::id _Tid = this_thread::get_id(); unique_lock _Lock(_My_mutex); @@ -967,15 +954,6 @@ public: return true; } - template - _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { - // try to lock the mutex with timeout -#if _HAS_CXX20 - static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); -#endif // _HAS_CXX20 - return _Try_lock_until(_Abs_time); - } - private: mutex _My_mutex; condition_variable _My_cond; diff --git a/stl/inc/shared_mutex b/stl/inc/shared_mutex index 824596e26a..dfc004bb0c 100644 --- a/stl/inc/shared_mutex +++ b/stl/inc/shared_mutex @@ -166,8 +166,12 @@ public: return try_lock_shared_until(_To_absolute_time(_Rel_time)); } - template - bool _Try_lock_shared_until(_Time _Abs_time) { // try to lock non-exclusive until absolute time + template + _NODISCARD_TRY_CHANGE_STATE bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + // try to lock non-exclusive until absolute time +#if _HAS_CXX20 + static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); +#endif // _HAS_CXX20 const auto _Can_acquire = [this] { return !_Writing && _Readers < _Max_readers; }; unique_lock _Lock(_Mymtx); @@ -180,15 +184,6 @@ public: return true; } - template - _NODISCARD_TRY_CHANGE_STATE bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { - // try to lock non-exclusive until absolute time -#if _HAS_CXX20 - static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); -#endif // _HAS_CXX20 - return _Try_lock_shared_until(_Abs_time); - } - void unlock_shared() { // unlock non-exclusive _Read_cnt_t _Local_readers; bool _Local_writing;