File indexing completed on 2025-01-18 09:54:51
0001
0002
0003
0004
0005 #ifndef CPPCORO_CANCELLATION_TOKEN_HPP_INCLUDED
0006 #define CPPCORO_CANCELLATION_TOKEN_HPP_INCLUDED
0007
0008 namespace cppcoro
0009 {
0010 class cancellation_source;
0011 class cancellation_registration;
0012
0013 namespace detail
0014 {
0015 class cancellation_state;
0016 }
0017
0018 class cancellation_token
0019 {
0020 public:
0021
0022
0023 cancellation_token() noexcept;
0024
0025
0026
0027
0028 cancellation_token(const cancellation_token& other) noexcept;
0029
0030 cancellation_token(cancellation_token&& other) noexcept;
0031
0032 ~cancellation_token();
0033
0034 cancellation_token& operator=(const cancellation_token& other) noexcept;
0035
0036 cancellation_token& operator=(cancellation_token&& other) noexcept;
0037
0038 void swap(cancellation_token& other) noexcept;
0039
0040
0041
0042
0043
0044
0045 bool can_be_cancelled() const noexcept;
0046
0047
0048
0049 bool is_cancellation_requested() const noexcept;
0050
0051
0052
0053 void throw_if_cancellation_requested() const;
0054
0055 private:
0056
0057 friend class cancellation_source;
0058 friend class cancellation_registration;
0059
0060 cancellation_token(detail::cancellation_state* state) noexcept;
0061
0062 detail::cancellation_state* m_state;
0063
0064 };
0065
0066 inline void swap(cancellation_token& a, cancellation_token& b) noexcept
0067 {
0068 a.swap(b);
0069 }
0070 }
0071
0072 #endif