File indexing completed on 2025-01-18 09:28:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_BASE_FROM_CANCELLATION_STATE_HPP
0012 #define BOOST_ASIO_DETAIL_BASE_FROM_CANCELLATION_STATE_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/associated_cancellation_slot.hpp>
0020 #include <boost/asio/cancellation_state.hpp>
0021 #include <boost/asio/detail/type_traits.hpp>
0022
0023 #include <boost/asio/detail/push_options.hpp>
0024
0025 namespace boost {
0026 namespace asio {
0027 namespace detail {
0028
0029 template <typename Handler, typename = void>
0030 class base_from_cancellation_state
0031 {
0032 public:
0033 typedef cancellation_slot cancellation_slot_type;
0034
0035 cancellation_slot_type get_cancellation_slot() const noexcept
0036 {
0037 return cancellation_state_.slot();
0038 }
0039
0040 cancellation_state get_cancellation_state() const noexcept
0041 {
0042 return cancellation_state_;
0043 }
0044
0045 protected:
0046 explicit base_from_cancellation_state(const Handler& handler)
0047 : cancellation_state_(
0048 boost::asio::get_associated_cancellation_slot(handler))
0049 {
0050 }
0051
0052 template <typename Filter>
0053 base_from_cancellation_state(const Handler& handler, Filter filter)
0054 : cancellation_state_(
0055 boost::asio::get_associated_cancellation_slot(handler), filter, filter)
0056 {
0057 }
0058
0059 template <typename InFilter, typename OutFilter>
0060 base_from_cancellation_state(const Handler& handler,
0061 InFilter&& in_filter,
0062 OutFilter&& out_filter)
0063 : cancellation_state_(
0064 boost::asio::get_associated_cancellation_slot(handler),
0065 static_cast<InFilter&&>(in_filter),
0066 static_cast<OutFilter&&>(out_filter))
0067 {
0068 }
0069
0070 void reset_cancellation_state(const Handler& handler)
0071 {
0072 cancellation_state_ = cancellation_state(
0073 boost::asio::get_associated_cancellation_slot(handler));
0074 }
0075
0076 template <typename Filter>
0077 void reset_cancellation_state(const Handler& handler, Filter filter)
0078 {
0079 cancellation_state_ = cancellation_state(
0080 boost::asio::get_associated_cancellation_slot(handler), filter, filter);
0081 }
0082
0083 template <typename InFilter, typename OutFilter>
0084 void reset_cancellation_state(const Handler& handler,
0085 InFilter&& in_filter,
0086 OutFilter&& out_filter)
0087 {
0088 cancellation_state_ = cancellation_state(
0089 boost::asio::get_associated_cancellation_slot(handler),
0090 static_cast<InFilter&&>(in_filter),
0091 static_cast<OutFilter&&>(out_filter));
0092 }
0093
0094 cancellation_type_t cancelled() const noexcept
0095 {
0096 return cancellation_state_.cancelled();
0097 }
0098
0099 private:
0100 cancellation_state cancellation_state_;
0101 };
0102
0103 template <typename Handler>
0104 class base_from_cancellation_state<Handler,
0105 enable_if_t<
0106 is_same<
0107 typename associated_cancellation_slot<
0108 Handler, cancellation_slot
0109 >::asio_associated_cancellation_slot_is_unspecialised,
0110 void
0111 >::value
0112 >
0113 >
0114 {
0115 public:
0116 cancellation_state get_cancellation_state() const noexcept
0117 {
0118 return cancellation_state();
0119 }
0120
0121 protected:
0122 explicit base_from_cancellation_state(const Handler&)
0123 {
0124 }
0125
0126 template <typename Filter>
0127 base_from_cancellation_state(const Handler&, Filter)
0128 {
0129 }
0130
0131 template <typename InFilter, typename OutFilter>
0132 base_from_cancellation_state(const Handler&,
0133 InFilter&&,
0134 OutFilter&&)
0135 {
0136 }
0137
0138 void reset_cancellation_state(const Handler&)
0139 {
0140 }
0141
0142 template <typename Filter>
0143 void reset_cancellation_state(const Handler&, Filter)
0144 {
0145 }
0146
0147 template <typename InFilter, typename OutFilter>
0148 void reset_cancellation_state(const Handler&,
0149 InFilter&&,
0150 OutFilter&&)
0151 {
0152 }
0153
0154 constexpr cancellation_type_t cancelled() const noexcept
0155 {
0156 return cancellation_type::none;
0157 }
0158 };
0159
0160 }
0161 }
0162 }
0163
0164 #include <boost/asio/detail/pop_options.hpp>
0165
0166 #endif