1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// Define ~condition_variable.
10//
11// On some platforms ~condition_variable has been made trivial and the
12// definition is only provided for ABI compatibility.
13
14#include <__config>
15#include <__thread/support.h>
16
17#if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 9 || !_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
18# define NEEDS_CONDVAR_DESTRUCTOR
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
23
24#ifdef NEEDS_CONDVAR_DESTRUCTOR
25
26class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
27 __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
28
29public:
30 _LIBCPP_HIDE_FROM_ABI constexpr condition_variable() noexcept = default;
31
32 ~condition_variable();
33
34 condition_variable(const condition_variable&) = delete;
35 condition_variable& operator=(const condition_variable&) = delete;
36};
37
38condition_variable::~condition_variable() { __libcpp_condvar_destroy(cv: &__cv_); }
39#endif
40
41_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
42_LIBCPP_END_NAMESPACE_STD
43