[libcxx-commits] [libcxx] [libc++] std::condition_variable_any overloads accepting std::stop_token don't register for stop callbacks (PR #77099)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 10 11:03:35 PST 2024


================
@@ -257,23 +258,38 @@ condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Pe
 
 template <class _Lock, class _Predicate>
 bool condition_variable_any::wait(_Lock& __lock, stop_token __stoken, _Predicate __pred) {
-  while (!__stoken.stop_requested()) {
+  shared_ptr<mutex> __mut = __mut_;
----------------
huixie90 wrote:

I don't mind to be honest. It is bit unlucky that we both worked on this on the same day and ended up with two patches. I updated mine with your suggestion and added test that you discovered (request_stop in between check and wait).
if we are aiming to land this patch, it would be good to have some tests (maybe you can take mine as starting point). Let me know your thoughts and thank you for contribution

https://github.com/llvm/llvm-project/pull/77099


More information about the libcxx-commits mailing list