]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/windows/random_access_handle_service.hpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / boost / asio / windows / random_access_handle_service.hpp
1 //
2 // windows/random_access_handle_service.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2018 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_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
12 #define BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_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 #if defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
21
22 #if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
23 || defined(GENERATING_DOCUMENTATION)
24
25 #include <cstddef>
26 #include <boost/asio/async_result.hpp>
27 #include <boost/asio/detail/cstdint.hpp>
28 #include <boost/asio/detail/win_iocp_handle_service.hpp>
29 #include <boost/asio/error.hpp>
30 #include <boost/asio/io_context.hpp>
31
32 #include <boost/asio/detail/push_options.hpp>
33
34 namespace boost {
35 namespace asio {
36 namespace windows {
37
38 /// Default service implementation for a random-access handle.
39 class random_access_handle_service
40 #if defined(GENERATING_DOCUMENTATION)
41 : public boost::asio::io_context::service
42 #else
43 : public boost::asio::detail::service_base<random_access_handle_service>
44 #endif
45 {
46 public:
47 #if defined(GENERATING_DOCUMENTATION)
48 /// The unique service identifier.
49 static boost::asio::io_context::id id;
50 #endif
51
52 private:
53 // The type of the platform-specific implementation.
54 typedef detail::win_iocp_handle_service service_impl_type;
55
56 public:
57 /// The type of a random-access handle implementation.
58 #if defined(GENERATING_DOCUMENTATION)
59 typedef implementation_defined implementation_type;
60 #else
61 typedef service_impl_type::implementation_type implementation_type;
62 #endif
63
64 /// The native handle type.
65 #if defined(GENERATING_DOCUMENTATION)
66 typedef implementation_defined native_handle_type;
67 #else
68 typedef service_impl_type::native_handle_type native_handle_type;
69 #endif
70
71 /// Construct a new random-access handle service for the specified io_context.
72 explicit random_access_handle_service(boost::asio::io_context& io_context)
73 : boost::asio::detail::service_base<
74 random_access_handle_service>(io_context),
75 service_impl_(io_context)
76 {
77 }
78
79 /// Construct a new random-access handle implementation.
80 void construct(implementation_type& impl)
81 {
82 service_impl_.construct(impl);
83 }
84
85 #if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
86 /// Move-construct a new random-access handle implementation.
87 void move_construct(implementation_type& impl,
88 implementation_type& other_impl)
89 {
90 service_impl_.move_construct(impl, other_impl);
91 }
92
93 /// Move-assign from another random-access handle implementation.
94 void move_assign(implementation_type& impl,
95 random_access_handle_service& other_service,
96 implementation_type& other_impl)
97 {
98 service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
99 }
100 #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
101
102 /// Destroy a random-access handle implementation.
103 void destroy(implementation_type& impl)
104 {
105 service_impl_.destroy(impl);
106 }
107
108 /// Assign an existing native handle to a random-access handle.
109 BOOST_ASIO_SYNC_OP_VOID assign(implementation_type& impl,
110 const native_handle_type& handle, boost::system::error_code& ec)
111 {
112 service_impl_.assign(impl, handle, ec);
113 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
114 }
115
116 /// Determine whether the handle is open.
117 bool is_open(const implementation_type& impl) const
118 {
119 return service_impl_.is_open(impl);
120 }
121
122 /// Close a random-access handle implementation.
123 BOOST_ASIO_SYNC_OP_VOID close(implementation_type& impl,
124 boost::system::error_code& ec)
125 {
126 service_impl_.close(impl, ec);
127 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
128 }
129
130 /// Get the native handle implementation.
131 native_handle_type native_handle(implementation_type& impl)
132 {
133 return service_impl_.native_handle(impl);
134 }
135
136 /// Cancel all asynchronous operations associated with the handle.
137 BOOST_ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
138 boost::system::error_code& ec)
139 {
140 service_impl_.cancel(impl, ec);
141 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
142 }
143
144 /// Write the given data at the specified offset.
145 template <typename ConstBufferSequence>
146 std::size_t write_some_at(implementation_type& impl, uint64_t offset,
147 const ConstBufferSequence& buffers, boost::system::error_code& ec)
148 {
149 return service_impl_.write_some_at(impl, offset, buffers, ec);
150 }
151
152 /// Start an asynchronous write at the specified offset.
153 template <typename ConstBufferSequence, typename WriteHandler>
154 BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
155 void (boost::system::error_code, std::size_t))
156 async_write_some_at(implementation_type& impl,
157 uint64_t offset, const ConstBufferSequence& buffers,
158 BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
159 {
160 boost::asio::async_completion<WriteHandler,
161 void (boost::system::error_code, std::size_t)> init(handler);
162
163 service_impl_.async_write_some_at(impl,
164 offset, buffers, init.completion_handler);
165
166 return init.result.get();
167 }
168
169 /// Read some data from the specified offset.
170 template <typename MutableBufferSequence>
171 std::size_t read_some_at(implementation_type& impl, uint64_t offset,
172 const MutableBufferSequence& buffers, boost::system::error_code& ec)
173 {
174 return service_impl_.read_some_at(impl, offset, buffers, ec);
175 }
176
177 /// Start an asynchronous read at the specified offset.
178 template <typename MutableBufferSequence, typename ReadHandler>
179 BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
180 void (boost::system::error_code, std::size_t))
181 async_read_some_at(implementation_type& impl,
182 uint64_t offset, const MutableBufferSequence& buffers,
183 BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
184 {
185 boost::asio::async_completion<ReadHandler,
186 void (boost::system::error_code, std::size_t)> init(handler);
187
188 service_impl_.async_read_some_at(impl,
189 offset, buffers, init.completion_handler);
190
191 return init.result.get();
192 }
193
194 private:
195 // Destroy all user-defined handler objects owned by the service.
196 void shutdown()
197 {
198 service_impl_.shutdown();
199 }
200
201 // The platform-specific implementation.
202 service_impl_type service_impl_;
203 };
204
205 } // namespace windows
206 } // namespace asio
207 } // namespace boost
208
209 #include <boost/asio/detail/pop_options.hpp>
210
211 #endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
212 // || defined(GENERATING_DOCUMENTATION)
213
214 #endif // defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
215
216 #endif // BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP