[libcxx-commits] [libcxx] [libc++][test][NFC] remove unused variables in the test (PR #179038)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 31 06:28:17 PST 2026
https://github.com/huixie90 created https://github.com/llvm/llvm-project/pull/179038
None
>From 2101525bf9eace08243e64c158155b56e69d7fa1 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Sat, 31 Jan 2026 14:27:50 +0000
Subject: [PATCH] [libc++][test][NFC] remove unused variables in the test
---
.../thread.semaphore/lost_wakeup.timed.pass.cpp | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/libcxx/test/std/thread/thread.semaphore/lost_wakeup.timed.pass.cpp b/libcxx/test/std/thread/thread.semaphore/lost_wakeup.timed.pass.cpp
index aa18b8fc61a39..a6099a6800c7d 100644
--- a/libcxx/test/std/thread/thread.semaphore/lost_wakeup.timed.pass.cpp
+++ b/libcxx/test/std/thread/thread.semaphore/lost_wakeup.timed.pass.cpp
@@ -14,27 +14,25 @@
// Test that counting_semaphore::try_acquire_for does not suffer from lost wakeup
// under stress testing.
-#include <barrier>
#include <chrono>
+#include <functional>
#include <semaphore>
#include <thread>
#include <vector>
#include "make_test_thread.h"
-static std::counting_semaphore<> s(0);
constexpr auto num_acquirer = 100;
constexpr auto num_iterations = 5000;
-static std::barrier<> b(num_acquirer + 1);
-void acquire() {
+void acquire(std::counting_semaphore<>& s) {
for (int i = 0; i < num_iterations; ++i) {
while (!s.try_acquire_for(std::chrono::seconds(1))) {
}
}
}
-void release() {
+void release(std::counting_semaphore<>& s) {
for (int i = 0; i < num_iterations; ++i) {
s.release(num_acquirer);
}
@@ -42,11 +40,11 @@ void release() {
int main(int, char**) {
std::vector<std::thread> threads;
+ std::counting_semaphore<> s(0);
for (int i = 0; i < num_acquirer; ++i)
- threads.push_back(support::make_test_thread(acquire));
-
- threads.push_back(support::make_test_thread(release));
+ threads.push_back(support::make_test_thread(acquire, std::ref(s)));
+ threads.push_back(support::make_test_thread(release, std::ref(s)));
for (auto& thread : threads)
thread.join();
More information about the libcxx-commits
mailing list