2 // cancellation_type.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_CANCELLATION_TYPE_HPP
12 #define BOOST_ASIO_CANCELLATION_TYPE_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #include <boost/asio/detail/push_options.hpp>
25 # if defined(GENERATING_DOCUMENTATION)
27 /// Enumeration representing the different types of cancellation that may
28 /// be requested from or implemented by an asynchronous operation.
29 enum cancellation_type
31 /// Bitmask representing no types of cancellation.
34 /// Requests cancellation where, following a successful cancellation, the only
35 /// safe operations on the I/O object are closure or destruction.
38 /// Requests cancellation where a successful cancellation may result in
39 /// partial side effects or no side effects. Following cancellation, the I/O
40 /// object is in a well-known state, and may be used for further operations.
43 /// Requests cancellation where a successful cancellation results in no
44 /// apparent side effects. Following cancellation, the I/O object is in the
45 /// same observable state as it was prior to the operation.
48 /// Bitmask representing all types of cancellation.
52 /// Portability typedef.
53 typedef cancellation_type cancellation_type_t;
55 #elif defined(BOOST_ASIO_HAS_ENUM_CLASS)
57 enum class cancellation_type : unsigned int
66 typedef cancellation_type cancellation_type_t;
68 #else // defined(BOOST_ASIO_HAS_ENUM_CLASS)
70 namespace cancellation_type {
72 enum cancellation_type_t
81 } // namespace cancellation_type
83 typedef cancellation_type::cancellation_type_t cancellation_type_t;
85 #endif // defined(BOOST_ASIO_HAS_ENUM_CLASS)
87 /// Negation operator.
89 * @relates cancellation_type
91 inline BOOST_ASIO_CONSTEXPR bool operator!(cancellation_type_t x)
93 return static_cast<unsigned int>(x) == 0;
96 /// Bitwise and operator.
98 * @relates cancellation_type
100 inline BOOST_ASIO_CONSTEXPR cancellation_type_t operator&(
101 cancellation_type_t x, cancellation_type_t y)
103 return static_cast<cancellation_type_t>(
104 static_cast<unsigned int>(x) & static_cast<unsigned int>(y));
107 /// Bitwise or operator.
109 * @relates cancellation_type
111 inline BOOST_ASIO_CONSTEXPR cancellation_type_t operator|(
112 cancellation_type_t x, cancellation_type_t y)
114 return static_cast<cancellation_type_t>(
115 static_cast<unsigned int>(x) | static_cast<unsigned int>(y));
118 /// Bitwise xor operator.
120 * @relates cancellation_type
122 inline BOOST_ASIO_CONSTEXPR cancellation_type_t operator^(
123 cancellation_type_t x, cancellation_type_t y)
125 return static_cast<cancellation_type_t>(
126 static_cast<unsigned int>(x) ^ static_cast<unsigned int>(y));
129 /// Bitwise negation operator.
131 * @relates cancellation_type
133 inline BOOST_ASIO_CONSTEXPR cancellation_type_t operator~(cancellation_type_t x)
135 return static_cast<cancellation_type_t>(~static_cast<unsigned int>(x));
138 /// Bitwise and-assignment operator.
140 * @relates cancellation_type
142 inline cancellation_type_t& operator&=(
143 cancellation_type_t& x, cancellation_type_t y)
149 /// Bitwise or-assignment operator.
151 * @relates cancellation_type
153 inline cancellation_type_t& operator|=(
154 cancellation_type_t& x, cancellation_type_t y)
160 /// Bitwise xor-assignment operator.
162 * @relates cancellation_type
164 inline cancellation_type_t& operator^=(
165 cancellation_type_t& x, cancellation_type_t y)
174 #include <boost/asio/detail/pop_options.hpp>
176 #endif // BOOST_ASIO_CANCELLATION_TYPE_HPP