[libcxx-commits] [libcxx] Fix async test (PR #146240)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jun 28 14:00:32 PDT 2025
https://github.com/EricWF created https://github.com/llvm/llvm-project/pull/146240
It seems to me the intention of `in_async.wait(...)` was to wait for the value to be set to true, which requires a call of `wait(false)` (waits if value matches argument).
As a drive by change scoped_lock to unique_lock, since there shouldn't be any functional difference between the two in this test.
Alternatively, the test could be written with a condition variable directly.
>From 06a816ea63c9338f80f9ea5a77bfc7e1c38f1143 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 16:57:38 -0400
Subject: [PATCH] Fix async test
It seems to me the intention of `in_async.wait(...)` was to wait
for the value to be set to true, which requires a call of `wait(false)`
(waits if value matches argument).
As a drive by change scoped_lock to unique_lock, since there
shouldn't be any functional difference between the two in this test.
Alternatively, the test could be written with a condition variable
directly.
---
.../thread/futures/futures.async/wait_on_destruct.pass.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index 8260ec3dfcaf4..6ab9f1d0b1afb 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -30,11 +30,11 @@ int main(int, char**) {
auto v = std::async(std::launch::async, [&in_async, value = 1]() mutable {
in_async = true;
in_async.notify_all();
- std::scoped_lock thread_lock(mux);
+ std::unique_lock thread_lock(mux);
value = 4;
(void)value;
});
- in_async.wait(true);
+ in_async.wait(false);
lock.unlock();
return 0;
More information about the libcxx-commits
mailing list