[libcxx-commits] [libcxx] 2002a59 - [libc++][test][NFC] remove unused and global variables in the test (#179038)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Feb 7 07:30:34 PST 2026


Author: Hui
Date: 2026-02-07T15:30:29Z
New Revision: 2002a5926c32a168ae1a40a2231ff57a2a0d28d6

URL: https://github.com/llvm/llvm-project/commit/2002a5926c32a168ae1a40a2231ff57a2a0d28d6
DIFF: https://github.com/llvm/llvm-project/commit/2002a5926c32a168ae1a40a2231ff57a2a0d28d6.diff

LOG: [libc++][test][NFC] remove unused and global variables in the test (#179038)

Fixes #178855

Added: 
    

Modified: 
    libcxx/test/std/thread/thread.semaphore/lost_wakeup.timed.pass.cpp

Removed: 
    


################################################################################
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