[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:46 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Hui (huixie90)
<details>
<summary>Changes</summary>
Fixes #<!-- -->178855
---
Full diff: https://github.com/llvm/llvm-project/pull/179038.diff
1 Files Affected:
- (modified) libcxx/test/std/thread/thread.semaphore/lost_wakeup.timed.pass.cpp (+6-8)
``````````diff
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/179038
More information about the libcxx-commits
mailing list