1 //===---------------- condition_variable_destructor.cpp ------------------===// 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 "__threading_support" 16 17 #if !defined(_LIBCPP_HAS_NO_THREADS) 18 # if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION) 19 # define NEEDS_CONDVAR_DESTRUCTOR 20 # endif 21 #endif 22 23 _LIBCPP_BEGIN_NAMESPACE_STD 24 25 #ifdef NEEDS_CONDVAR_DESTRUCTOR 26 27 class _LIBCPP_TYPE_VIS condition_variable 28 { 29 __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; 30 public: 31 _LIBCPP_INLINE_VISIBILITY 32 constexpr condition_variable() noexcept = default; 33 34 ~condition_variable(); 35 36 condition_variable(const condition_variable&) = delete; 37 condition_variable& operator=(const condition_variable&) = delete; 38 }; 39 40 condition_variable::~condition_variable() 41 { 42 __libcpp_condvar_destroy(&__cv_); 43 } 44 #endif 45 46 _LIBCPP_END_NAMESPACE_STD 47