[libcxx-commits] [libcxx] [libc++] std::barrier uses native wait (PR #171041)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Dec 7 07:04:10 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Hui (huixie90)

<details>
<summary>Changes</summary>

not sure why but the current `std::barrier` implementation the wait implementation is polling on the loop instead of using the native wait

---
Full diff: https://github.com/llvm/llvm-project/pull/171041.diff


1 Files Affected:

- (modified) libcxx/include/barrier (+1-2) 


``````````diff
diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 5f9b471f01741..10d40f32919c8 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -142,8 +142,7 @@ public:
     return __old_phase;
   }
   _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __old_phase) const {
-    auto const __test_fn = [this, __old_phase]() -> bool { return __phase_.load(memory_order_acquire) != __old_phase; };
-    std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
+    __phase_.wait(__old_phase, std::memory_order_acquire);
   }
   _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() {
     __expected_adjustment_.fetch_sub(1, memory_order_relaxed);

``````````

</details>


https://github.com/llvm/llvm-project/pull/171041


More information about the libcxx-commits mailing list