// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_LATCH #define _LIBCPP_LATCH /* latch synopsis namespace std { class latch // since C++20 { public: static constexpr ptrdiff_t max() noexcept; constexpr explicit latch(ptrdiff_t __expected); ~latch(); latch(const latch&) = delete; latch& operator=(const latch&) = delete; void count_down(ptrdiff_t __update = 1); bool try_wait() const noexcept; void wait() const; void arrive_and_wait(ptrdiff_t __update = 1); private: ptrdiff_t __counter; // exposition only }; } */ #include <__config> #if !defined(_LIBCPP_HAS_NO_THREADS) # include <__assert> # include <__atomic/atomic_base.h> # include <__atomic/atomic_sync.h> # include <__atomic/memory_order.h> # include <cstddef> # include <limits> # include <version> # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header # endif _LIBCPP_PUSH_MACROS # include <__undef_macros> # if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD class latch { … }; _LIBCPP_END_NAMESPACE_STD # endif // _LIBCPP_STD_VER >= 20 _LIBCPP_POP_MACROS #endif // !defined(_LIBCPP_HAS_NO_THREADS) #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> #endif #endif // _LIBCPP_LATCH