[libcxx-commits] [libcxx] [libc++] Save duration/timeout locally for condition_variable waits (PR #148330)
John Sheu via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jul 12 04:10:49 PDT 2025
johnsheu wrote:
The relevant lines in the `std::condition_variable_any` implementation are highlighted here:
```c++
template <class _Lock, class _Clock, class _Duration>
_LIBCPP_HIDE_FROM_ABI cv_status wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t) {
shared_ptr<mutex> __mut = __mut_;
unique_lock<mutex> __lk(*__mut);
// User-supplied lock is unlocked here
__unlock_guard<_Lock> __unlock(__lock);
lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t());
// User-supplied reference parameter is used here; bad news if it was protected by the above lock
return __cv_.wait_until(__lk, __t);
} // __mut_.unlock(), __lock.lock()
```
https://github.com/llvm/llvm-project/pull/148330
More information about the libcxx-commits
mailing list