12 #ifndef ASIO_DETAIL_WIN_IOCP_HANDLE_SERVICE_HPP 13 #define ASIO_DETAIL_WIN_IOCP_HANDLE_SERVICE_HPP 15 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 21 #if defined(ASIO_HAS_IOCP) 40 class win_iocp_handle_service
44 typedef HANDLE native_handle_type;
47 class implementation_type
52 : handle_(INVALID_HANDLE_VALUE),
53 safe_cancellation_thread_id_(0),
61 friend class win_iocp_handle_service;
64 native_handle_type handle_;
70 DWORD safe_cancellation_thread_id_;
73 implementation_type* next_;
74 implementation_type* prev_;
83 ASIO_DECL void construct(implementation_type& impl);
86 ASIO_DECL void move_construct(implementation_type& impl,
87 implementation_type& other_impl);
90 ASIO_DECL void move_assign(implementation_type& impl,
91 win_iocp_handle_service& other_service,
92 implementation_type& other_impl);
95 ASIO_DECL void destroy(implementation_type& impl);
102 bool is_open(
const implementation_type& impl)
const 104 return impl.handle_ != INVALID_HANDLE_VALUE;
112 native_handle_type native_handle(
const implementation_type& impl)
const 122 template <
typename ConstBufferSequence>
123 size_t write_some(implementation_type& impl,
126 return write_some_at(impl, 0, buffers, ec);
131 template <
typename ConstBufferSequence>
132 size_t write_some_at(implementation_type& impl, uint64_t
offset,
137 ConstBufferSequence>::first(buffers);
139 return do_write(impl, offset, buffer, ec);
144 template <
typename ConstBufferSequence,
typename Handler>
145 void async_write_some(implementation_type& impl,
146 const ConstBufferSequence&
buffers, Handler& handler)
149 typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op;
150 typename op::ptr p = { asio::detail::addressof(handler),
152 sizeof(op), handler), 0 };
153 p.p =
new (p.v) op(buffers, handler);
157 start_write_op(impl, 0,
159 ConstBufferSequence>::first(buffers), p.p);
165 template <
typename ConstBufferSequence,
typename Handler>
166 void async_write_some_at(implementation_type& impl, uint64_t
offset,
167 const ConstBufferSequence& buffers, Handler& handler)
170 typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op;
171 typename op::ptr p = { asio::detail::addressof(handler),
173 sizeof(op), handler), 0 };
174 p.p =
new (p.v) op(buffers, handler);
178 start_write_op(impl, offset,
180 ConstBufferSequence>::first(buffers), p.p);
185 template <
typename MutableBufferSequence>
186 size_t read_some(implementation_type& impl,
189 return read_some_at(impl, 0, buffers, ec);
193 template <
typename MutableBufferSequence>
194 size_t read_some_at(implementation_type& impl, uint64_t offset,
199 MutableBufferSequence>::first(buffers);
201 return do_read(impl, offset, buffer, ec);
206 template <
typename MutableBufferSequence,
typename Handler>
207 void async_read_some(implementation_type& impl,
208 const MutableBufferSequence& buffers, Handler& handler)
211 typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op;
212 typename op::ptr p = { asio::detail::addressof(handler),
214 sizeof(op), handler), 0 };
215 p.p =
new (p.v) op(buffers, handler);
219 start_read_op(impl, 0,
221 MutableBufferSequence>::first(buffers), p.p);
228 template <
typename MutableBufferSequence,
typename Handler>
229 void async_read_some_at(implementation_type& impl, uint64_t offset,
230 const MutableBufferSequence& buffers, Handler& handler)
233 typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op;
234 typename op::ptr p = { asio::detail::addressof(handler),
236 sizeof(op), handler), 0 };
237 p.p =
new (p.v) op(buffers, handler);
241 start_read_op(impl, offset,
243 MutableBufferSequence>::first(buffers), p.p);
249 size_t write_some(implementation_type& impl,
251 size_t write_some_at(implementation_type& impl, uint64_t offset,
253 template <
typename Handler>
254 void async_write_some(implementation_type& impl,
255 const null_buffers& buffers, Handler& handler);
256 template <
typename Handler>
257 void async_write_some_at(implementation_type& impl, uint64_t offset,
258 const null_buffers& buffers, Handler& handler);
259 size_t read_some(implementation_type& impl,
261 size_t read_some_at(implementation_type& impl, uint64_t offset,
263 template <
typename Handler>
264 void async_read_some(implementation_type& impl,
265 const null_buffers& buffers, Handler& handler);
266 template <
typename Handler>
267 void async_read_some_at(implementation_type& impl, uint64_t offset,
268 const null_buffers& buffers, Handler& handler);
271 class overlapped_wrapper;
274 ASIO_DECL size_t do_write(implementation_type& impl,
279 ASIO_DECL void start_write_op(implementation_type& impl,
284 ASIO_DECL size_t do_read(implementation_type& impl,
289 ASIO_DECL void start_read_op(implementation_type& impl,
294 ASIO_DECL void update_cancellation_thread_id(implementation_type& impl);
298 ASIO_DECL void close_for_destruction(implementation_type& impl);
302 win_iocp_io_service& iocp_service_;
308 implementation_type* impl_list_;
316 #if defined(ASIO_HEADER_ONLY) 318 #endif // defined(ASIO_HEADER_ONLY) 320 #endif // defined(ASIO_HAS_IOCP) 322 #endif // ASIO_DETAIL_WIN_IOCP_HANDLE_SERVICE_HPP
Provides core I/O functionality.
Holds a buffer that cannot be modified.
mutable_buffers_1 buffer(const mutable_buffer &b)
Create a new modifiable buffer from an existing buffer.
const MutableBufferSequence & buffers
Holds a buffer that can be modified.
Class to represent an error code value.
task_io_service_operation operation
ASIO_DECL int close(int d, state_type &state, asio::error_code &ec)
void * allocate(std::size_t s, Handler &h)
#define ASIO_HANDLER_CREATION(args)