Skip to content

Commit 6ce071d

Browse files
committed
[libc++] std::barrier uses native wait
1 parent 73a1383 commit 6ce071d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libcxx/include/barrier

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ namespace std
5454

5555
# include <__assert>
5656
# include <__atomic/atomic.h>
57+
# include <__atomic/atomic_sync.h>
5758
# include <__atomic/memory_order.h>
5859
# include <__cstddef/ptrdiff_t.h>
5960
# include <__memory/unique_ptr.h>
@@ -142,8 +143,9 @@ public:
142143
return __old_phase;
143144
}
144145
_LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __old_phase) const {
145-
auto const __test_fn = [this, __old_phase]() -> bool { return __phase_.load(memory_order_acquire) != __old_phase; };
146-
std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
146+
std::__atomic_wait_unless(__phase_, memory_order_acquire, [this, &__old_phase](arrival_token& __value) -> bool {
147+
return __old_phase != __value;
148+
});
147149
}
148150
_LIBCPP_HIDE_FROM_ABI void arrive_and_drop() {
149151
__expected_adjustment_.fetch_sub(1, memory_order_relaxed);

0 commit comments

Comments
 (0)