[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __cxx03 / __stop_token / stop_token.h
blobbba5cd1c4796eda72b6130c71eac4add8f04c46c
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
11 #define _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
13 #include <__cxx03/__config>
14 #include <__cxx03/__stop_token/intrusive_shared_ptr.h>
15 #include <__cxx03/__stop_token/stop_state.h>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 # pragma GCC system_header
19 #endif
21 _LIBCPP_BEGIN_NAMESPACE_STD
23 #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
25 class _LIBCPP_AVAILABILITY_SYNC stop_token {
26 public:
27 _LIBCPP_HIDE_FROM_ABI stop_token() noexcept = default;
29 _LIBCPP_HIDE_FROM_ABI stop_token(const stop_token&) noexcept = default;
30 _LIBCPP_HIDE_FROM_ABI stop_token(stop_token&&) noexcept = default;
31 _LIBCPP_HIDE_FROM_ABI stop_token& operator=(const stop_token&) noexcept = default;
32 _LIBCPP_HIDE_FROM_ABI stop_token& operator=(stop_token&&) noexcept = default;
33 _LIBCPP_HIDE_FROM_ABI ~stop_token() = default;
35 _LIBCPP_HIDE_FROM_ABI void swap(stop_token& __other) noexcept { __state_.swap(__other.__state_); }
37 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool stop_requested() const noexcept {
38 return __state_ != nullptr && __state_->__stop_requested();
41 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool stop_possible() const noexcept {
42 return __state_ != nullptr && __state_->__stop_possible_for_stop_token();
45 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend bool operator==(const stop_token&, const stop_token&) noexcept = default;
47 _LIBCPP_HIDE_FROM_ABI friend void swap(stop_token& __lhs, stop_token& __rhs) noexcept { __lhs.swap(__rhs); }
49 private:
50 __intrusive_shared_ptr<__stop_state> __state_;
52 friend class stop_source;
53 template <class _Tp>
54 friend class stop_callback;
56 _LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {}
59 #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
61 _LIBCPP_END_NAMESPACE_STD
63 #endif // _LIBCPP___STOP_TOKEN_STOP_TOKEN_H