30#define _GLIBCXX_LATCH 1
33#pragma GCC system_header
38#define __glibcxx_want_latch
45namespace std _GLIBCXX_VISIBILITY(default)
47_GLIBCXX_BEGIN_NAMESPACE_VERSION
52 static constexpr ptrdiff_t
56 constexpr explicit latch(ptrdiff_t __expected) noexcept
57 : _M_a(__expected) { }
60 latch(
const latch&) =
delete;
61 latch& operator=(
const latch&) =
delete;
63 _GLIBCXX_ALWAYS_INLINE
void
64 count_down(ptrdiff_t __update = 1)
66 __glibcxx_assert(__update >= 0);
67 auto const __old = __atomic_impl::fetch_sub(&_M_a,
68 __update, memory_order::release);
69 __glibcxx_assert(__update >= 0);
70 if (__old ==
static_cast<__detail::__platform_wait_t
>(__update))
71 __atomic_impl::notify_all(&_M_a);
74 _GLIBCXX_ALWAYS_INLINE
bool
75 try_wait() const noexcept
76 {
return __atomic_impl::load(&_M_a, memory_order::acquire) == 0; }
78 _GLIBCXX_ALWAYS_INLINE
void
81 auto const __pred = [
this] {
return this->try_wait(); };
82 std::__atomic_wait_address(&_M_a, __pred);
85 _GLIBCXX_ALWAYS_INLINE
void
86 arrive_and_wait(ptrdiff_t __update = 1) noexcept
95 alignas(__alignof__(__detail::__platform_wait_t)) __detail::__platform_wait_t _M_a;
97_GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.