File indexing completed on 2025-01-18 09:29:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP
0012 #define BOOST_ASIO_WINDOWS_OVERLAPPED_PTR_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR) \
0021 || defined(GENERATING_DOCUMENTATION)
0022
0023 #include <boost/asio/detail/noncopyable.hpp>
0024 #include <boost/asio/detail/win_iocp_overlapped_ptr.hpp>
0025 #include <boost/asio/io_context.hpp>
0026
0027 #include <boost/asio/detail/push_options.hpp>
0028
0029 namespace boost {
0030 namespace asio {
0031 namespace windows {
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 class overlapped_ptr
0043 : private noncopyable
0044 {
0045 public:
0046
0047 overlapped_ptr()
0048 : impl_()
0049 {
0050 }
0051
0052
0053 template <typename ExecutionContext, typename Handler>
0054 explicit overlapped_ptr(ExecutionContext& context,
0055 Handler&& handler,
0056 constraint_t<
0057 is_convertible<ExecutionContext&, execution_context&>::value
0058 > = 0)
0059 : impl_(context.get_executor(), static_cast<Handler&&>(handler))
0060 {
0061 }
0062
0063
0064 template <typename Executor, typename Handler>
0065 explicit overlapped_ptr(const Executor& ex,
0066 Handler&& handler,
0067 constraint_t<
0068 execution::is_executor<Executor>::value
0069 || is_executor<Executor>::value
0070 > = 0)
0071 : impl_(ex, static_cast<Handler&&>(handler))
0072 {
0073 }
0074
0075
0076 ~overlapped_ptr()
0077 {
0078 }
0079
0080
0081 void reset()
0082 {
0083 impl_.reset();
0084 }
0085
0086
0087
0088 template <typename ExecutionContext, typename Handler>
0089 void reset(ExecutionContext& context, Handler&& handler,
0090 constraint_t<
0091 is_convertible<ExecutionContext&, execution_context&>::value
0092 > = 0)
0093 {
0094 impl_.reset(context.get_executor(), static_cast<Handler&&>(handler));
0095 }
0096
0097
0098
0099 template <typename Executor, typename Handler>
0100 void reset(const Executor& ex, Handler&& handler,
0101 constraint_t<
0102 execution::is_executor<Executor>::value
0103 || is_executor<Executor>::value
0104 > = 0)
0105 {
0106 impl_.reset(ex, static_cast<Handler&&>(handler));
0107 }
0108
0109
0110 OVERLAPPED* get()
0111 {
0112 return impl_.get();
0113 }
0114
0115
0116 const OVERLAPPED* get() const
0117 {
0118 return impl_.get();
0119 }
0120
0121
0122 OVERLAPPED* release()
0123 {
0124 return impl_.release();
0125 }
0126
0127
0128 void complete(const boost::system::error_code& ec,
0129 std::size_t bytes_transferred)
0130 {
0131 impl_.complete(ec, bytes_transferred);
0132 }
0133
0134 private:
0135 detail::win_iocp_overlapped_ptr impl_;
0136 };
0137
0138 }
0139 }
0140 }
0141
0142 #include <boost/asio/detail/pop_options.hpp>
0143
0144 #endif
0145
0146
0147 #endif