annotate DEPENDENCIES/generic/include/boost/asio/windows/random_access_handle_service.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // windows/random_access_handle_service.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
Chris@16 12 #define BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19
Chris@16 20 #if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
Chris@16 21 || defined(GENERATING_DOCUMENTATION)
Chris@16 22
Chris@16 23 #include <cstddef>
Chris@16 24 #include <boost/asio/async_result.hpp>
Chris@16 25 #include <boost/asio/detail/cstdint.hpp>
Chris@16 26 #include <boost/asio/detail/win_iocp_handle_service.hpp>
Chris@16 27 #include <boost/asio/error.hpp>
Chris@16 28 #include <boost/asio/io_service.hpp>
Chris@16 29
Chris@16 30 #include <boost/asio/detail/push_options.hpp>
Chris@16 31
Chris@16 32 namespace boost {
Chris@16 33 namespace asio {
Chris@16 34 namespace windows {
Chris@16 35
Chris@16 36 /// Default service implementation for a random-access handle.
Chris@16 37 class random_access_handle_service
Chris@16 38 #if defined(GENERATING_DOCUMENTATION)
Chris@16 39 : public boost::asio::io_service::service
Chris@16 40 #else
Chris@16 41 : public boost::asio::detail::service_base<random_access_handle_service>
Chris@16 42 #endif
Chris@16 43 {
Chris@16 44 public:
Chris@16 45 #if defined(GENERATING_DOCUMENTATION)
Chris@16 46 /// The unique service identifier.
Chris@16 47 static boost::asio::io_service::id id;
Chris@16 48 #endif
Chris@16 49
Chris@16 50 private:
Chris@16 51 // The type of the platform-specific implementation.
Chris@16 52 typedef detail::win_iocp_handle_service service_impl_type;
Chris@16 53
Chris@16 54 public:
Chris@16 55 /// The type of a random-access handle implementation.
Chris@16 56 #if defined(GENERATING_DOCUMENTATION)
Chris@16 57 typedef implementation_defined implementation_type;
Chris@16 58 #else
Chris@16 59 typedef service_impl_type::implementation_type implementation_type;
Chris@16 60 #endif
Chris@16 61
Chris@16 62 /// (Deprecated: Use native_handle_type.) The native handle type.
Chris@16 63 #if defined(GENERATING_DOCUMENTATION)
Chris@16 64 typedef implementation_defined native_type;
Chris@16 65 #else
Chris@16 66 typedef service_impl_type::native_handle_type native_type;
Chris@16 67 #endif
Chris@16 68
Chris@16 69 /// The native handle type.
Chris@16 70 #if defined(GENERATING_DOCUMENTATION)
Chris@16 71 typedef implementation_defined native_handle_type;
Chris@16 72 #else
Chris@16 73 typedef service_impl_type::native_handle_type native_handle_type;
Chris@16 74 #endif
Chris@16 75
Chris@16 76 /// Construct a new random-access handle service for the specified io_service.
Chris@16 77 explicit random_access_handle_service(boost::asio::io_service& io_service)
Chris@16 78 : boost::asio::detail::service_base<
Chris@16 79 random_access_handle_service>(io_service),
Chris@16 80 service_impl_(io_service)
Chris@16 81 {
Chris@16 82 }
Chris@16 83
Chris@16 84 /// Construct a new random-access handle implementation.
Chris@16 85 void construct(implementation_type& impl)
Chris@16 86 {
Chris@16 87 service_impl_.construct(impl);
Chris@16 88 }
Chris@16 89
Chris@16 90 #if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
Chris@16 91 /// Move-construct a new random-access handle implementation.
Chris@16 92 void move_construct(implementation_type& impl,
Chris@16 93 implementation_type& other_impl)
Chris@16 94 {
Chris@16 95 service_impl_.move_construct(impl, other_impl);
Chris@16 96 }
Chris@16 97
Chris@16 98 /// Move-assign from another random-access handle implementation.
Chris@16 99 void move_assign(implementation_type& impl,
Chris@16 100 random_access_handle_service& other_service,
Chris@16 101 implementation_type& other_impl)
Chris@16 102 {
Chris@16 103 service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
Chris@16 104 }
Chris@16 105 #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
Chris@16 106
Chris@16 107 /// Destroy a random-access handle implementation.
Chris@16 108 void destroy(implementation_type& impl)
Chris@16 109 {
Chris@16 110 service_impl_.destroy(impl);
Chris@16 111 }
Chris@16 112
Chris@16 113 /// Assign an existing native handle to a random-access handle.
Chris@16 114 boost::system::error_code assign(implementation_type& impl,
Chris@16 115 const native_handle_type& handle, boost::system::error_code& ec)
Chris@16 116 {
Chris@16 117 return service_impl_.assign(impl, handle, ec);
Chris@16 118 }
Chris@16 119
Chris@16 120 /// Determine whether the handle is open.
Chris@16 121 bool is_open(const implementation_type& impl) const
Chris@16 122 {
Chris@16 123 return service_impl_.is_open(impl);
Chris@16 124 }
Chris@16 125
Chris@16 126 /// Close a random-access handle implementation.
Chris@16 127 boost::system::error_code close(implementation_type& impl,
Chris@16 128 boost::system::error_code& ec)
Chris@16 129 {
Chris@16 130 return service_impl_.close(impl, ec);
Chris@16 131 }
Chris@16 132
Chris@16 133 /// (Deprecated: Use native_handle().) Get the native handle implementation.
Chris@16 134 native_type native(implementation_type& impl)
Chris@16 135 {
Chris@16 136 return service_impl_.native_handle(impl);
Chris@16 137 }
Chris@16 138
Chris@16 139 /// Get the native handle implementation.
Chris@16 140 native_handle_type native_handle(implementation_type& impl)
Chris@16 141 {
Chris@16 142 return service_impl_.native_handle(impl);
Chris@16 143 }
Chris@16 144
Chris@16 145 /// Cancel all asynchronous operations associated with the handle.
Chris@16 146 boost::system::error_code cancel(implementation_type& impl,
Chris@16 147 boost::system::error_code& ec)
Chris@16 148 {
Chris@16 149 return service_impl_.cancel(impl, ec);
Chris@16 150 }
Chris@16 151
Chris@16 152 /// Write the given data at the specified offset.
Chris@16 153 template <typename ConstBufferSequence>
Chris@16 154 std::size_t write_some_at(implementation_type& impl, uint64_t offset,
Chris@16 155 const ConstBufferSequence& buffers, boost::system::error_code& ec)
Chris@16 156 {
Chris@16 157 return service_impl_.write_some_at(impl, offset, buffers, ec);
Chris@16 158 }
Chris@16 159
Chris@16 160 /// Start an asynchronous write at the specified offset.
Chris@16 161 template <typename ConstBufferSequence, typename WriteHandler>
Chris@16 162 BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
Chris@16 163 void (boost::system::error_code, std::size_t))
Chris@16 164 async_write_some_at(implementation_type& impl,
Chris@16 165 uint64_t offset, const ConstBufferSequence& buffers,
Chris@16 166 BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
Chris@16 167 {
Chris@16 168 boost::asio::detail::async_result_init<
Chris@16 169 WriteHandler, void (boost::system::error_code, std::size_t)> init(
Chris@16 170 BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
Chris@16 171
Chris@16 172 service_impl_.async_write_some_at(impl, offset, buffers, init.handler);
Chris@16 173
Chris@16 174 return init.result.get();
Chris@16 175 }
Chris@16 176
Chris@16 177 /// Read some data from the specified offset.
Chris@16 178 template <typename MutableBufferSequence>
Chris@16 179 std::size_t read_some_at(implementation_type& impl, uint64_t offset,
Chris@16 180 const MutableBufferSequence& buffers, boost::system::error_code& ec)
Chris@16 181 {
Chris@16 182 return service_impl_.read_some_at(impl, offset, buffers, ec);
Chris@16 183 }
Chris@16 184
Chris@16 185 /// Start an asynchronous read at the specified offset.
Chris@16 186 template <typename MutableBufferSequence, typename ReadHandler>
Chris@16 187 BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
Chris@16 188 void (boost::system::error_code, std::size_t))
Chris@16 189 async_read_some_at(implementation_type& impl,
Chris@16 190 uint64_t offset, const MutableBufferSequence& buffers,
Chris@16 191 BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
Chris@16 192 {
Chris@16 193 boost::asio::detail::async_result_init<
Chris@16 194 ReadHandler, void (boost::system::error_code, std::size_t)> init(
Chris@16 195 BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
Chris@16 196
Chris@16 197 service_impl_.async_read_some_at(impl, offset, buffers, init.handler);
Chris@16 198
Chris@16 199 return init.result.get();
Chris@16 200 }
Chris@16 201
Chris@16 202 private:
Chris@16 203 // Destroy all user-defined handler objects owned by the service.
Chris@16 204 void shutdown_service()
Chris@16 205 {
Chris@16 206 service_impl_.shutdown_service();
Chris@16 207 }
Chris@16 208
Chris@16 209 // The platform-specific implementation.
Chris@16 210 service_impl_type service_impl_;
Chris@16 211 };
Chris@16 212
Chris@16 213 } // namespace windows
Chris@16 214 } // namespace asio
Chris@16 215 } // namespace boost
Chris@16 216
Chris@16 217 #include <boost/asio/detail/pop_options.hpp>
Chris@16 218
Chris@16 219 #endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
Chris@16 220 // || defined(GENERATING_DOCUMENTATION)
Chris@16 221
Chris@16 222 #endif // BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP