1//
2// cancellation_type.hpp
3// ~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
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)
9//
10
11#ifndef BOOST_ASIO_CANCELLATION_TYPE_HPP
12#define BOOST_ASIO_CANCELLATION_TYPE_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19
20#include <boost/asio/detail/push_options.hpp>
21
22namespace boost {
23namespace asio {
24
25# if defined(GENERATING_DOCUMENTATION)
26
27/// Enumeration representing the different types of cancellation that may
28/// be requested from or implemented by an asynchronous operation.
29enum cancellation_type
30{
31 /// Bitmask representing no types of cancellation.
32 none = 0,
33
34 /// Requests cancellation where, following a successful cancellation, the only
35 /// safe operations on the I/O object are closure or destruction.
36 terminal = 1,
37
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.
41 partial = 2,
42
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.
46 total = 4,
47
48 /// Bitmask representing all types of cancellation.
49 all = 0xFFFFFFFF
50};
51
52/// Portability typedef.
53typedef cancellation_type cancellation_type_t;
54
55#else // defined(GENERATING_DOCUMENTATION)
56
57enum class cancellation_type : unsigned int
58{
59 none = 0,
60 terminal = 1,
61 partial = 2,
62 total = 4,
63 all = 0xFFFFFFFF
64};
65
66typedef cancellation_type cancellation_type_t;
67
68#endif // defined(GENERATING_DOCUMENTATION)
69
70/// Negation operator.
71/**
72 * @relates cancellation_type
73 */
74inline constexpr bool operator!(cancellation_type_t x)
75{
76 return static_cast<unsigned int>(x) == 0;
77}
78
79/// Bitwise and operator.
80/**
81 * @relates cancellation_type
82 */
83inline constexpr cancellation_type_t operator&(
84 cancellation_type_t x, cancellation_type_t y)
85{
86 return static_cast<cancellation_type_t>(
87 static_cast<unsigned int>(x) & static_cast<unsigned int>(y));
88}
89
90/// Bitwise or operator.
91/**
92 * @relates cancellation_type
93 */
94inline constexpr cancellation_type_t operator|(
95 cancellation_type_t x, cancellation_type_t y)
96{
97 return static_cast<cancellation_type_t>(
98 static_cast<unsigned int>(x) | static_cast<unsigned int>(y));
99}
100
101/// Bitwise xor operator.
102/**
103 * @relates cancellation_type
104 */
105inline constexpr cancellation_type_t operator^(
106 cancellation_type_t x, cancellation_type_t y)
107{
108 return static_cast<cancellation_type_t>(
109 static_cast<unsigned int>(x) ^ static_cast<unsigned int>(y));
110}
111
112/// Bitwise negation operator.
113/**
114 * @relates cancellation_type
115 */
116inline constexpr cancellation_type_t operator~(cancellation_type_t x)
117{
118 return static_cast<cancellation_type_t>(~static_cast<unsigned int>(x));
119}
120
121/// Bitwise and-assignment operator.
122/**
123 * @relates cancellation_type
124 */
125inline cancellation_type_t& operator&=(
126 cancellation_type_t& x, cancellation_type_t y)
127{
128 x = x & y;
129 return x;
130}
131
132/// Bitwise or-assignment operator.
133/**
134 * @relates cancellation_type
135 */
136inline cancellation_type_t& operator|=(
137 cancellation_type_t& x, cancellation_type_t y)
138{
139 x = x | y;
140 return x;
141}
142
143/// Bitwise xor-assignment operator.
144/**
145 * @relates cancellation_type
146 */
147inline cancellation_type_t& operator^=(
148 cancellation_type_t& x, cancellation_type_t y)
149{
150 x = x ^ y;
151 return x;
152}
153
154} // namespace asio
155} // namespace boost
156
157#include <boost/asio/detail/pop_options.hpp>
158
159#endif // BOOST_ASIO_CANCELLATION_TYPE_HPP
160

source code of boost/libs/asio/include/boost/asio/cancellation_type.hpp