xref: /freebsd-src/contrib/llvm-project/libcxx/src/condition_variable_destructor.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric // Define ~condition_variable.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric // On some platforms ~condition_variable has been made trivial and the
120b57cec5SDimitry Andric // definition is only provided for ABI compatibility.
130b57cec5SDimitry Andric 
1481ad6265SDimitry Andric #include <__config>
15*0fca6ea1SDimitry Andric #include <__thread/support.h>
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)
180b57cec5SDimitry Andric #  define NEEDS_CONDVAR_DESTRUCTOR
190b57cec5SDimitry Andric #endif
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric #ifdef NEEDS_CONDVAR_DESTRUCTOR
240b57cec5SDimitry Andric 
25cb14a3feSDimitry Andric class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
260b57cec5SDimitry Andric   __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
27cb14a3feSDimitry Andric 
280b57cec5SDimitry Andric public:
29cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI constexpr condition_variable() noexcept = default;
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric   ~condition_variable();
320b57cec5SDimitry Andric 
330b57cec5SDimitry Andric   condition_variable(const condition_variable&)            = delete;
340b57cec5SDimitry Andric   condition_variable& operator=(const condition_variable&) = delete;
350b57cec5SDimitry Andric };
360b57cec5SDimitry Andric 
37cb14a3feSDimitry Andric condition_variable::~condition_variable() { __libcpp_condvar_destroy(&__cv_); }
380b57cec5SDimitry Andric #endif
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric _LIBCPP_END_NAMESPACE_STD
41