aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui <hui.xie1990@gmail.com>2024-03-24 20:52:47 +0000
committerGitHub <noreply@github.com>2024-03-24 20:52:47 +0000
commit81e2693c1202d6c4e48dbf2d985153b03cfccb79 (patch)
tree190ce8650d2ee50853db83b59c8a11f4571d707e
parent9f0321ccf118b37e5cb93cabd2acbf600c36b6ee (diff)
downloadllvm-81e2693c1202d6c4e48dbf2d985153b03cfccb79.zip
llvm-81e2693c1202d6c4e48dbf2d985153b03cfccb79.tar.gz
llvm-81e2693c1202d6c4e48dbf2d985153b03cfccb79.tar.bz2
[libc++][test] Fix race condition in condition_variable_any tests (#84788)
Some tests in `condition_variable_any` use two `shared_lock` to guard, which does not work. The fix is to make the writer to use `unique_lock`
-rw-r--r--libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_token_pred.pass.cpp2
-rw-r--r--libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_token_pred.pass.cpp2
-rw-r--r--libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_token_pred.pass.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_token_pred.pass.cpp b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_token_pred.pass.cpp
index 4ea6055..7a39d12 100644
--- a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_token_pred.pass.cpp
+++ b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_token_pred.pass.cpp
@@ -119,7 +119,7 @@ void test() {
bool flag = false;
auto thread = support::make_test_thread([&]() {
std::this_thread::sleep_for(2ms);
- Lock lock2{mutex};
+ std::unique_lock<Mutex> lock2{mutex};
flag = true;
cv.notify_all();
});
diff --git a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_token_pred.pass.cpp b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_token_pred.pass.cpp
index e96a3e8..f322d8c 100644
--- a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_token_pred.pass.cpp
+++ b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_token_pred.pass.cpp
@@ -63,7 +63,7 @@ void test() {
bool flag = false;
auto thread = support::make_test_thread([&]() {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
- Lock lock2{mutex};
+ std::unique_lock<Mutex> lock2{mutex};
flag = true;
cv.notify_all();
});
diff --git a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_token_pred.pass.cpp b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_token_pred.pass.cpp
index d649db0..e7388b9 100644
--- a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_token_pred.pass.cpp
+++ b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_token_pred.pass.cpp
@@ -119,7 +119,7 @@ void test() {
bool flag = false;
auto thread = support::make_test_thread([&]() {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
- Lock lock2{mutex};
+ std::unique_lock<Mutex> lock2{mutex};
flag = true;
cv.notify_all();
});