Chris@16
|
1 //
|
Chris@16
|
2 // impl/read_at.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_IMPL_READ_AT_HPP
|
Chris@16
|
12 #define BOOST_ASIO_IMPL_READ_AT_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 <algorithm>
|
Chris@16
|
19 #include <boost/asio/buffer.hpp>
|
Chris@16
|
20 #include <boost/asio/completion_condition.hpp>
|
Chris@16
|
21 #include <boost/asio/detail/array_fwd.hpp>
|
Chris@16
|
22 #include <boost/asio/detail/base_from_completion_cond.hpp>
|
Chris@16
|
23 #include <boost/asio/detail/bind_handler.hpp>
|
Chris@16
|
24 #include <boost/asio/detail/consuming_buffers.hpp>
|
Chris@16
|
25 #include <boost/asio/detail/dependent_type.hpp>
|
Chris@16
|
26 #include <boost/asio/detail/handler_alloc_helpers.hpp>
|
Chris@16
|
27 #include <boost/asio/detail/handler_cont_helpers.hpp>
|
Chris@16
|
28 #include <boost/asio/detail/handler_invoke_helpers.hpp>
|
Chris@16
|
29 #include <boost/asio/detail/handler_type_requirements.hpp>
|
Chris@16
|
30 #include <boost/asio/detail/throw_error.hpp>
|
Chris@16
|
31 #include <boost/asio/error.hpp>
|
Chris@16
|
32
|
Chris@16
|
33 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
34
|
Chris@16
|
35 namespace boost {
|
Chris@16
|
36 namespace asio {
|
Chris@16
|
37
|
Chris@16
|
38 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
39 typename CompletionCondition>
|
Chris@16
|
40 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
41 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
42 CompletionCondition completion_condition, boost::system::error_code& ec)
|
Chris@16
|
43 {
|
Chris@16
|
44 ec = boost::system::error_code();
|
Chris@16
|
45 boost::asio::detail::consuming_buffers<
|
Chris@16
|
46 mutable_buffer, MutableBufferSequence> tmp(buffers);
|
Chris@16
|
47 std::size_t total_transferred = 0;
|
Chris@16
|
48 tmp.prepare(detail::adapt_completion_condition_result(
|
Chris@16
|
49 completion_condition(ec, total_transferred)));
|
Chris@16
|
50 while (tmp.begin() != tmp.end())
|
Chris@16
|
51 {
|
Chris@16
|
52 std::size_t bytes_transferred = d.read_some_at(
|
Chris@16
|
53 offset + total_transferred, tmp, ec);
|
Chris@16
|
54 tmp.consume(bytes_transferred);
|
Chris@16
|
55 total_transferred += bytes_transferred;
|
Chris@16
|
56 tmp.prepare(detail::adapt_completion_condition_result(
|
Chris@16
|
57 completion_condition(ec, total_transferred)));
|
Chris@16
|
58 }
|
Chris@16
|
59 return total_transferred;
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
|
Chris@16
|
63 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
64 uint64_t offset, const MutableBufferSequence& buffers)
|
Chris@16
|
65 {
|
Chris@16
|
66 boost::system::error_code ec;
|
Chris@16
|
67 std::size_t bytes_transferred = read_at(
|
Chris@16
|
68 d, offset, buffers, transfer_all(), ec);
|
Chris@16
|
69 boost::asio::detail::throw_error(ec, "read_at");
|
Chris@16
|
70 return bytes_transferred;
|
Chris@16
|
71 }
|
Chris@16
|
72
|
Chris@16
|
73 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
|
Chris@16
|
74 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
75 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
76 boost::system::error_code& ec)
|
Chris@16
|
77 {
|
Chris@16
|
78 return read_at(d, offset, buffers, transfer_all(), ec);
|
Chris@16
|
79 }
|
Chris@16
|
80
|
Chris@16
|
81 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
82 typename CompletionCondition>
|
Chris@16
|
83 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
84 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
85 CompletionCondition completion_condition)
|
Chris@16
|
86 {
|
Chris@16
|
87 boost::system::error_code ec;
|
Chris@16
|
88 std::size_t bytes_transferred = read_at(
|
Chris@16
|
89 d, offset, buffers, completion_condition, ec);
|
Chris@16
|
90 boost::asio::detail::throw_error(ec, "read_at");
|
Chris@16
|
91 return bytes_transferred;
|
Chris@16
|
92 }
|
Chris@16
|
93
|
Chris@16
|
94 #if !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
95
|
Chris@16
|
96 template <typename SyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
97 typename CompletionCondition>
|
Chris@16
|
98 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
99 uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
|
Chris@16
|
100 CompletionCondition completion_condition, boost::system::error_code& ec)
|
Chris@16
|
101 {
|
Chris@16
|
102 ec = boost::system::error_code();
|
Chris@16
|
103 std::size_t total_transferred = 0;
|
Chris@16
|
104 std::size_t max_size = detail::adapt_completion_condition_result(
|
Chris@16
|
105 completion_condition(ec, total_transferred));
|
Chris@16
|
106 std::size_t bytes_available = read_size_helper(b, max_size);
|
Chris@16
|
107 while (bytes_available > 0)
|
Chris@16
|
108 {
|
Chris@16
|
109 std::size_t bytes_transferred = d.read_some_at(
|
Chris@16
|
110 offset + total_transferred, b.prepare(bytes_available), ec);
|
Chris@16
|
111 b.commit(bytes_transferred);
|
Chris@16
|
112 total_transferred += bytes_transferred;
|
Chris@16
|
113 max_size = detail::adapt_completion_condition_result(
|
Chris@16
|
114 completion_condition(ec, total_transferred));
|
Chris@16
|
115 bytes_available = read_size_helper(b, max_size);
|
Chris@16
|
116 }
|
Chris@16
|
117 return total_transferred;
|
Chris@16
|
118 }
|
Chris@16
|
119
|
Chris@16
|
120 template <typename SyncRandomAccessReadDevice, typename Allocator>
|
Chris@16
|
121 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
122 uint64_t offset, boost::asio::basic_streambuf<Allocator>& b)
|
Chris@16
|
123 {
|
Chris@16
|
124 boost::system::error_code ec;
|
Chris@16
|
125 std::size_t bytes_transferred = read_at(
|
Chris@16
|
126 d, offset, b, transfer_all(), ec);
|
Chris@16
|
127 boost::asio::detail::throw_error(ec, "read_at");
|
Chris@16
|
128 return bytes_transferred;
|
Chris@16
|
129 }
|
Chris@16
|
130
|
Chris@16
|
131 template <typename SyncRandomAccessReadDevice, typename Allocator>
|
Chris@16
|
132 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
133 uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
|
Chris@16
|
134 boost::system::error_code& ec)
|
Chris@16
|
135 {
|
Chris@16
|
136 return read_at(d, offset, b, transfer_all(), ec);
|
Chris@16
|
137 }
|
Chris@16
|
138
|
Chris@16
|
139 template <typename SyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
140 typename CompletionCondition>
|
Chris@16
|
141 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
142 uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
|
Chris@16
|
143 CompletionCondition completion_condition)
|
Chris@16
|
144 {
|
Chris@16
|
145 boost::system::error_code ec;
|
Chris@16
|
146 std::size_t bytes_transferred = read_at(
|
Chris@16
|
147 d, offset, b, completion_condition, ec);
|
Chris@16
|
148 boost::asio::detail::throw_error(ec, "read_at");
|
Chris@16
|
149 return bytes_transferred;
|
Chris@16
|
150 }
|
Chris@16
|
151
|
Chris@16
|
152 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
153
|
Chris@16
|
154 namespace detail
|
Chris@16
|
155 {
|
Chris@16
|
156 template <typename AsyncRandomAccessReadDevice,
|
Chris@16
|
157 typename MutableBufferSequence, typename CompletionCondition,
|
Chris@16
|
158 typename ReadHandler>
|
Chris@16
|
159 class read_at_op
|
Chris@16
|
160 : detail::base_from_completion_cond<CompletionCondition>
|
Chris@16
|
161 {
|
Chris@16
|
162 public:
|
Chris@16
|
163 read_at_op(AsyncRandomAccessReadDevice& device,
|
Chris@16
|
164 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
165 CompletionCondition completion_condition, ReadHandler& handler)
|
Chris@16
|
166 : detail::base_from_completion_cond<
|
Chris@16
|
167 CompletionCondition>(completion_condition),
|
Chris@16
|
168 device_(device),
|
Chris@16
|
169 offset_(offset),
|
Chris@16
|
170 buffers_(buffers),
|
Chris@16
|
171 start_(0),
|
Chris@16
|
172 total_transferred_(0),
|
Chris@16
|
173 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
Chris@16
|
174 {
|
Chris@16
|
175 }
|
Chris@16
|
176
|
Chris@16
|
177 #if defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
178 read_at_op(const read_at_op& other)
|
Chris@16
|
179 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
180 device_(other.device_),
|
Chris@16
|
181 offset_(other.offset_),
|
Chris@16
|
182 buffers_(other.buffers_),
|
Chris@16
|
183 start_(other.start_),
|
Chris@16
|
184 total_transferred_(other.total_transferred_),
|
Chris@16
|
185 handler_(other.handler_)
|
Chris@16
|
186 {
|
Chris@16
|
187 }
|
Chris@16
|
188
|
Chris@16
|
189 read_at_op(read_at_op&& other)
|
Chris@16
|
190 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
191 device_(other.device_),
|
Chris@16
|
192 offset_(other.offset_),
|
Chris@16
|
193 buffers_(other.buffers_),
|
Chris@16
|
194 start_(other.start_),
|
Chris@16
|
195 total_transferred_(other.total_transferred_),
|
Chris@16
|
196 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
Chris@16
|
197 {
|
Chris@16
|
198 }
|
Chris@16
|
199 #endif // defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
200
|
Chris@16
|
201 void operator()(const boost::system::error_code& ec,
|
Chris@16
|
202 std::size_t bytes_transferred, int start = 0)
|
Chris@16
|
203 {
|
Chris@16
|
204 switch (start_ = start)
|
Chris@16
|
205 {
|
Chris@16
|
206 case 1:
|
Chris@16
|
207 buffers_.prepare(this->check_for_completion(ec, total_transferred_));
|
Chris@16
|
208 for (;;)
|
Chris@16
|
209 {
|
Chris@16
|
210 device_.async_read_some_at(offset_ + total_transferred_,
|
Chris@16
|
211 buffers_, BOOST_ASIO_MOVE_CAST(read_at_op)(*this));
|
Chris@16
|
212 return; default:
|
Chris@16
|
213 total_transferred_ += bytes_transferred;
|
Chris@16
|
214 buffers_.consume(bytes_transferred);
|
Chris@16
|
215 buffers_.prepare(this->check_for_completion(ec, total_transferred_));
|
Chris@16
|
216 if ((!ec && bytes_transferred == 0)
|
Chris@16
|
217 || buffers_.begin() == buffers_.end())
|
Chris@16
|
218 break;
|
Chris@16
|
219 }
|
Chris@16
|
220
|
Chris@16
|
221 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
|
Chris@16
|
222 }
|
Chris@16
|
223 }
|
Chris@16
|
224
|
Chris@16
|
225 //private:
|
Chris@16
|
226 AsyncRandomAccessReadDevice& device_;
|
Chris@16
|
227 uint64_t offset_;
|
Chris@16
|
228 boost::asio::detail::consuming_buffers<
|
Chris@16
|
229 mutable_buffer, MutableBufferSequence> buffers_;
|
Chris@16
|
230 int start_;
|
Chris@16
|
231 std::size_t total_transferred_;
|
Chris@16
|
232 ReadHandler handler_;
|
Chris@16
|
233 };
|
Chris@16
|
234
|
Chris@16
|
235 template <typename AsyncRandomAccessReadDevice,
|
Chris@16
|
236 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
237 class read_at_op<AsyncRandomAccessReadDevice,
|
Chris@16
|
238 boost::asio::mutable_buffers_1, CompletionCondition, ReadHandler>
|
Chris@16
|
239 : detail::base_from_completion_cond<CompletionCondition>
|
Chris@16
|
240 {
|
Chris@16
|
241 public:
|
Chris@16
|
242 read_at_op(AsyncRandomAccessReadDevice& device,
|
Chris@16
|
243 uint64_t offset, const boost::asio::mutable_buffers_1& buffers,
|
Chris@16
|
244 CompletionCondition completion_condition, ReadHandler& handler)
|
Chris@16
|
245 : detail::base_from_completion_cond<
|
Chris@16
|
246 CompletionCondition>(completion_condition),
|
Chris@16
|
247 device_(device),
|
Chris@16
|
248 offset_(offset),
|
Chris@16
|
249 buffer_(buffers),
|
Chris@16
|
250 start_(0),
|
Chris@16
|
251 total_transferred_(0),
|
Chris@16
|
252 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
Chris@16
|
253 {
|
Chris@16
|
254 }
|
Chris@16
|
255
|
Chris@16
|
256 #if defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
257 read_at_op(const read_at_op& other)
|
Chris@16
|
258 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
259 device_(other.device_),
|
Chris@16
|
260 offset_(other.offset_),
|
Chris@16
|
261 buffer_(other.buffer_),
|
Chris@16
|
262 start_(other.start_),
|
Chris@16
|
263 total_transferred_(other.total_transferred_),
|
Chris@16
|
264 handler_(other.handler_)
|
Chris@16
|
265 {
|
Chris@16
|
266 }
|
Chris@16
|
267
|
Chris@16
|
268 read_at_op(read_at_op&& other)
|
Chris@16
|
269 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
270 device_(other.device_),
|
Chris@16
|
271 offset_(other.offset_),
|
Chris@16
|
272 buffer_(other.buffer_),
|
Chris@16
|
273 start_(other.start_),
|
Chris@16
|
274 total_transferred_(other.total_transferred_),
|
Chris@16
|
275 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
Chris@16
|
276 {
|
Chris@16
|
277 }
|
Chris@16
|
278 #endif // defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
279
|
Chris@16
|
280 void operator()(const boost::system::error_code& ec,
|
Chris@16
|
281 std::size_t bytes_transferred, int start = 0)
|
Chris@16
|
282 {
|
Chris@16
|
283 std::size_t n = 0;
|
Chris@16
|
284 switch (start_ = start)
|
Chris@16
|
285 {
|
Chris@16
|
286 case 1:
|
Chris@16
|
287 n = this->check_for_completion(ec, total_transferred_);
|
Chris@16
|
288 for (;;)
|
Chris@16
|
289 {
|
Chris@16
|
290 device_.async_read_some_at(offset_ + total_transferred_,
|
Chris@16
|
291 boost::asio::buffer(buffer_ + total_transferred_, n),
|
Chris@16
|
292 BOOST_ASIO_MOVE_CAST(read_at_op)(*this));
|
Chris@16
|
293 return; default:
|
Chris@16
|
294 total_transferred_ += bytes_transferred;
|
Chris@16
|
295 if ((!ec && bytes_transferred == 0)
|
Chris@16
|
296 || (n = this->check_for_completion(ec, total_transferred_)) == 0
|
Chris@16
|
297 || total_transferred_ == boost::asio::buffer_size(buffer_))
|
Chris@16
|
298 break;
|
Chris@16
|
299 }
|
Chris@16
|
300
|
Chris@16
|
301 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
|
Chris@16
|
302 }
|
Chris@16
|
303 }
|
Chris@16
|
304
|
Chris@16
|
305 //private:
|
Chris@16
|
306 AsyncRandomAccessReadDevice& device_;
|
Chris@16
|
307 uint64_t offset_;
|
Chris@16
|
308 boost::asio::mutable_buffer buffer_;
|
Chris@16
|
309 int start_;
|
Chris@16
|
310 std::size_t total_transferred_;
|
Chris@16
|
311 ReadHandler handler_;
|
Chris@16
|
312 };
|
Chris@16
|
313
|
Chris@16
|
314 template <typename AsyncRandomAccessReadDevice, typename Elem,
|
Chris@16
|
315 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
316 class read_at_op<AsyncRandomAccessReadDevice, boost::array<Elem, 2>,
|
Chris@16
|
317 CompletionCondition, ReadHandler>
|
Chris@16
|
318 : detail::base_from_completion_cond<CompletionCondition>
|
Chris@16
|
319 {
|
Chris@16
|
320 public:
|
Chris@16
|
321 read_at_op(AsyncRandomAccessReadDevice& device,
|
Chris@16
|
322 uint64_t offset, const boost::array<Elem, 2>& buffers,
|
Chris@16
|
323 CompletionCondition completion_condition, ReadHandler& handler)
|
Chris@16
|
324 : detail::base_from_completion_cond<
|
Chris@16
|
325 CompletionCondition>(completion_condition),
|
Chris@16
|
326 device_(device),
|
Chris@16
|
327 offset_(offset),
|
Chris@16
|
328 buffers_(buffers),
|
Chris@16
|
329 start_(0),
|
Chris@16
|
330 total_transferred_(0),
|
Chris@16
|
331 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
Chris@16
|
332 {
|
Chris@16
|
333 }
|
Chris@16
|
334
|
Chris@16
|
335 #if defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
336 read_at_op(const read_at_op& other)
|
Chris@16
|
337 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
338 device_(other.device_),
|
Chris@16
|
339 offset_(other.offset_),
|
Chris@16
|
340 buffers_(other.buffers_),
|
Chris@16
|
341 start_(other.start_),
|
Chris@16
|
342 total_transferred_(other.total_transferred_),
|
Chris@16
|
343 handler_(other.handler_)
|
Chris@16
|
344 {
|
Chris@16
|
345 }
|
Chris@16
|
346
|
Chris@16
|
347 read_at_op(read_at_op&& other)
|
Chris@16
|
348 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
349 device_(other.device_),
|
Chris@16
|
350 offset_(other.offset_),
|
Chris@16
|
351 buffers_(other.buffers_),
|
Chris@16
|
352 start_(other.start_),
|
Chris@16
|
353 total_transferred_(other.total_transferred_),
|
Chris@16
|
354 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
Chris@16
|
355 {
|
Chris@16
|
356 }
|
Chris@16
|
357 #endif // defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
358
|
Chris@16
|
359 void operator()(const boost::system::error_code& ec,
|
Chris@16
|
360 std::size_t bytes_transferred, int start = 0)
|
Chris@16
|
361 {
|
Chris@16
|
362 typename boost::asio::detail::dependent_type<Elem,
|
Chris@16
|
363 boost::array<boost::asio::mutable_buffer, 2> >::type bufs = {{
|
Chris@16
|
364 boost::asio::mutable_buffer(buffers_[0]),
|
Chris@16
|
365 boost::asio::mutable_buffer(buffers_[1]) }};
|
Chris@16
|
366 std::size_t buffer_size0 = boost::asio::buffer_size(bufs[0]);
|
Chris@16
|
367 std::size_t buffer_size1 = boost::asio::buffer_size(bufs[1]);
|
Chris@16
|
368 std::size_t n = 0;
|
Chris@16
|
369 switch (start_ = start)
|
Chris@16
|
370 {
|
Chris@16
|
371 case 1:
|
Chris@16
|
372 n = this->check_for_completion(ec, total_transferred_);
|
Chris@16
|
373 for (;;)
|
Chris@16
|
374 {
|
Chris@16
|
375 bufs[0] = boost::asio::buffer(bufs[0] + total_transferred_, n);
|
Chris@16
|
376 bufs[1] = boost::asio::buffer(
|
Chris@16
|
377 bufs[1] + (total_transferred_ < buffer_size0
|
Chris@16
|
378 ? 0 : total_transferred_ - buffer_size0),
|
Chris@16
|
379 n - boost::asio::buffer_size(bufs[0]));
|
Chris@16
|
380 device_.async_read_some_at(offset_ + total_transferred_,
|
Chris@16
|
381 bufs, BOOST_ASIO_MOVE_CAST(read_at_op)(*this));
|
Chris@16
|
382 return; default:
|
Chris@16
|
383 total_transferred_ += bytes_transferred;
|
Chris@16
|
384 if ((!ec && bytes_transferred == 0)
|
Chris@16
|
385 || (n = this->check_for_completion(ec, total_transferred_)) == 0
|
Chris@16
|
386 || total_transferred_ == buffer_size0 + buffer_size1)
|
Chris@16
|
387 break;
|
Chris@16
|
388 }
|
Chris@16
|
389
|
Chris@16
|
390 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
|
Chris@16
|
391 }
|
Chris@16
|
392 }
|
Chris@16
|
393
|
Chris@16
|
394 //private:
|
Chris@16
|
395 AsyncRandomAccessReadDevice& device_;
|
Chris@16
|
396 uint64_t offset_;
|
Chris@16
|
397 boost::array<Elem, 2> buffers_;
|
Chris@16
|
398 int start_;
|
Chris@16
|
399 std::size_t total_transferred_;
|
Chris@16
|
400 ReadHandler handler_;
|
Chris@16
|
401 };
|
Chris@16
|
402
|
Chris@16
|
403 #if defined(BOOST_ASIO_HAS_STD_ARRAY)
|
Chris@16
|
404
|
Chris@16
|
405 template <typename AsyncRandomAccessReadDevice, typename Elem,
|
Chris@16
|
406 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
407 class read_at_op<AsyncRandomAccessReadDevice, std::array<Elem, 2>,
|
Chris@16
|
408 CompletionCondition, ReadHandler>
|
Chris@16
|
409 : detail::base_from_completion_cond<CompletionCondition>
|
Chris@16
|
410 {
|
Chris@16
|
411 public:
|
Chris@16
|
412 read_at_op(AsyncRandomAccessReadDevice& device,
|
Chris@16
|
413 uint64_t offset, const std::array<Elem, 2>& buffers,
|
Chris@16
|
414 CompletionCondition completion_condition, ReadHandler& handler)
|
Chris@16
|
415 : detail::base_from_completion_cond<
|
Chris@16
|
416 CompletionCondition>(completion_condition),
|
Chris@16
|
417 device_(device),
|
Chris@16
|
418 offset_(offset),
|
Chris@16
|
419 buffers_(buffers),
|
Chris@16
|
420 start_(0),
|
Chris@16
|
421 total_transferred_(0),
|
Chris@16
|
422 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
Chris@16
|
423 {
|
Chris@16
|
424 }
|
Chris@16
|
425
|
Chris@16
|
426 #if defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
427 read_at_op(const read_at_op& other)
|
Chris@16
|
428 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
429 device_(other.device_),
|
Chris@16
|
430 offset_(other.offset_),
|
Chris@16
|
431 buffers_(other.buffers_),
|
Chris@16
|
432 start_(other.start_),
|
Chris@16
|
433 total_transferred_(other.total_transferred_),
|
Chris@16
|
434 handler_(other.handler_)
|
Chris@16
|
435 {
|
Chris@16
|
436 }
|
Chris@16
|
437
|
Chris@16
|
438 read_at_op(read_at_op&& other)
|
Chris@16
|
439 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
440 device_(other.device_),
|
Chris@16
|
441 offset_(other.offset_),
|
Chris@16
|
442 buffers_(other.buffers_),
|
Chris@16
|
443 start_(other.start_),
|
Chris@16
|
444 total_transferred_(other.total_transferred_),
|
Chris@16
|
445 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
Chris@16
|
446 {
|
Chris@16
|
447 }
|
Chris@16
|
448 #endif // defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
449
|
Chris@16
|
450 void operator()(const boost::system::error_code& ec,
|
Chris@16
|
451 std::size_t bytes_transferred, int start = 0)
|
Chris@16
|
452 {
|
Chris@16
|
453 typename boost::asio::detail::dependent_type<Elem,
|
Chris@16
|
454 std::array<boost::asio::mutable_buffer, 2> >::type bufs = {{
|
Chris@16
|
455 boost::asio::mutable_buffer(buffers_[0]),
|
Chris@16
|
456 boost::asio::mutable_buffer(buffers_[1]) }};
|
Chris@16
|
457 std::size_t buffer_size0 = boost::asio::buffer_size(bufs[0]);
|
Chris@16
|
458 std::size_t buffer_size1 = boost::asio::buffer_size(bufs[1]);
|
Chris@16
|
459 std::size_t n = 0;
|
Chris@16
|
460 switch (start_ = start)
|
Chris@16
|
461 {
|
Chris@16
|
462 case 1:
|
Chris@16
|
463 n = this->check_for_completion(ec, total_transferred_);
|
Chris@16
|
464 for (;;)
|
Chris@16
|
465 {
|
Chris@16
|
466 bufs[0] = boost::asio::buffer(bufs[0] + total_transferred_, n);
|
Chris@16
|
467 bufs[1] = boost::asio::buffer(
|
Chris@16
|
468 bufs[1] + (total_transferred_ < buffer_size0
|
Chris@16
|
469 ? 0 : total_transferred_ - buffer_size0),
|
Chris@16
|
470 n - boost::asio::buffer_size(bufs[0]));
|
Chris@16
|
471 device_.async_read_some_at(offset_ + total_transferred_,
|
Chris@16
|
472 bufs, BOOST_ASIO_MOVE_CAST(read_at_op)(*this));
|
Chris@16
|
473 return; default:
|
Chris@16
|
474 total_transferred_ += bytes_transferred;
|
Chris@16
|
475 if ((!ec && bytes_transferred == 0)
|
Chris@16
|
476 || (n = this->check_for_completion(ec, total_transferred_)) == 0
|
Chris@16
|
477 || total_transferred_ == buffer_size0 + buffer_size1)
|
Chris@16
|
478 break;
|
Chris@16
|
479 }
|
Chris@16
|
480
|
Chris@16
|
481 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
|
Chris@16
|
482 }
|
Chris@16
|
483 }
|
Chris@16
|
484
|
Chris@16
|
485 //private:
|
Chris@16
|
486 AsyncRandomAccessReadDevice& device_;
|
Chris@16
|
487 uint64_t offset_;
|
Chris@16
|
488 std::array<Elem, 2> buffers_;
|
Chris@16
|
489 int start_;
|
Chris@16
|
490 std::size_t total_transferred_;
|
Chris@16
|
491 ReadHandler handler_;
|
Chris@16
|
492 };
|
Chris@16
|
493
|
Chris@16
|
494 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
Chris@16
|
495
|
Chris@16
|
496 template <typename AsyncRandomAccessReadDevice,
|
Chris@16
|
497 typename MutableBufferSequence, typename CompletionCondition,
|
Chris@16
|
498 typename ReadHandler>
|
Chris@16
|
499 inline void* asio_handler_allocate(std::size_t size,
|
Chris@16
|
500 read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
Chris@16
|
501 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
502 {
|
Chris@16
|
503 return boost_asio_handler_alloc_helpers::allocate(
|
Chris@16
|
504 size, this_handler->handler_);
|
Chris@16
|
505 }
|
Chris@16
|
506
|
Chris@16
|
507 template <typename AsyncRandomAccessReadDevice,
|
Chris@16
|
508 typename MutableBufferSequence, typename CompletionCondition,
|
Chris@16
|
509 typename ReadHandler>
|
Chris@16
|
510 inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
Chris@16
|
511 read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
Chris@16
|
512 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
513 {
|
Chris@16
|
514 boost_asio_handler_alloc_helpers::deallocate(
|
Chris@16
|
515 pointer, size, this_handler->handler_);
|
Chris@16
|
516 }
|
Chris@16
|
517
|
Chris@16
|
518 template <typename AsyncRandomAccessReadDevice,
|
Chris@16
|
519 typename MutableBufferSequence, typename CompletionCondition,
|
Chris@16
|
520 typename ReadHandler>
|
Chris@16
|
521 inline bool asio_handler_is_continuation(
|
Chris@16
|
522 read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
Chris@16
|
523 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
524 {
|
Chris@16
|
525 return this_handler->start_ == 0 ? true
|
Chris@16
|
526 : boost_asio_handler_cont_helpers::is_continuation(
|
Chris@16
|
527 this_handler->handler_);
|
Chris@16
|
528 }
|
Chris@16
|
529
|
Chris@16
|
530 template <typename Function, typename AsyncRandomAccessReadDevice,
|
Chris@16
|
531 typename MutableBufferSequence, typename CompletionCondition,
|
Chris@16
|
532 typename ReadHandler>
|
Chris@16
|
533 inline void asio_handler_invoke(Function& function,
|
Chris@16
|
534 read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
Chris@16
|
535 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
536 {
|
Chris@16
|
537 boost_asio_handler_invoke_helpers::invoke(
|
Chris@16
|
538 function, this_handler->handler_);
|
Chris@16
|
539 }
|
Chris@16
|
540
|
Chris@16
|
541 template <typename Function, typename AsyncRandomAccessReadDevice,
|
Chris@16
|
542 typename MutableBufferSequence, typename CompletionCondition,
|
Chris@16
|
543 typename ReadHandler>
|
Chris@16
|
544 inline void asio_handler_invoke(const Function& function,
|
Chris@16
|
545 read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
Chris@16
|
546 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
547 {
|
Chris@16
|
548 boost_asio_handler_invoke_helpers::invoke(
|
Chris@16
|
549 function, this_handler->handler_);
|
Chris@16
|
550 }
|
Chris@16
|
551
|
Chris@16
|
552 template <typename AsyncRandomAccessReadDevice,
|
Chris@16
|
553 typename MutableBufferSequence, typename CompletionCondition,
|
Chris@16
|
554 typename ReadHandler>
|
Chris@16
|
555 inline read_at_op<AsyncRandomAccessReadDevice,
|
Chris@16
|
556 MutableBufferSequence, CompletionCondition, ReadHandler>
|
Chris@16
|
557 make_read_at_op(AsyncRandomAccessReadDevice& d,
|
Chris@16
|
558 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
559 CompletionCondition completion_condition, ReadHandler handler)
|
Chris@16
|
560 {
|
Chris@16
|
561 return read_at_op<AsyncRandomAccessReadDevice,
|
Chris@16
|
562 MutableBufferSequence, CompletionCondition, ReadHandler>(
|
Chris@16
|
563 d, offset, buffers, completion_condition, handler);
|
Chris@16
|
564 }
|
Chris@16
|
565 } // namespace detail
|
Chris@16
|
566
|
Chris@16
|
567 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
568 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
569 inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
570 void (boost::system::error_code, std::size_t))
|
Chris@16
|
571 async_read_at(AsyncRandomAccessReadDevice& d,
|
Chris@16
|
572 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
573 CompletionCondition completion_condition,
|
Chris@16
|
574 BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
Chris@16
|
575 {
|
Chris@16
|
576 // If you get an error on the following line it means that your handler does
|
Chris@16
|
577 // not meet the documented type requirements for a ReadHandler.
|
Chris@16
|
578 BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
Chris@16
|
579
|
Chris@16
|
580 detail::async_result_init<
|
Chris@16
|
581 ReadHandler, void (boost::system::error_code, std::size_t)> init(
|
Chris@16
|
582 BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
Chris@16
|
583
|
Chris@16
|
584 detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
Chris@16
|
585 CompletionCondition, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
|
Chris@16
|
586 void (boost::system::error_code, std::size_t))>(
|
Chris@16
|
587 d, offset, buffers, completion_condition, init.handler)(
|
Chris@16
|
588 boost::system::error_code(), 0, 1);
|
Chris@16
|
589
|
Chris@16
|
590 return init.result.get();
|
Chris@16
|
591 }
|
Chris@16
|
592
|
Chris@16
|
593 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
594 typename ReadHandler>
|
Chris@16
|
595 inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
596 void (boost::system::error_code, std::size_t))
|
Chris@16
|
597 async_read_at(AsyncRandomAccessReadDevice& d,
|
Chris@16
|
598 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
599 BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
Chris@16
|
600 {
|
Chris@16
|
601 // If you get an error on the following line it means that your handler does
|
Chris@16
|
602 // not meet the documented type requirements for a ReadHandler.
|
Chris@16
|
603 BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
Chris@16
|
604
|
Chris@16
|
605 detail::async_result_init<
|
Chris@16
|
606 ReadHandler, void (boost::system::error_code, std::size_t)> init(
|
Chris@16
|
607 BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
Chris@16
|
608
|
Chris@16
|
609 detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
|
Chris@16
|
610 detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
|
Chris@16
|
611 void (boost::system::error_code, std::size_t))>(
|
Chris@16
|
612 d, offset, buffers, transfer_all(), init.handler)(
|
Chris@16
|
613 boost::system::error_code(), 0, 1);
|
Chris@16
|
614
|
Chris@16
|
615 return init.result.get();
|
Chris@16
|
616 }
|
Chris@16
|
617
|
Chris@16
|
618 #if !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
619
|
Chris@16
|
620 namespace detail
|
Chris@16
|
621 {
|
Chris@16
|
622 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
623 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
624 class read_at_streambuf_op
|
Chris@16
|
625 : detail::base_from_completion_cond<CompletionCondition>
|
Chris@16
|
626 {
|
Chris@16
|
627 public:
|
Chris@16
|
628 read_at_streambuf_op(AsyncRandomAccessReadDevice& device,
|
Chris@16
|
629 uint64_t offset, basic_streambuf<Allocator>& streambuf,
|
Chris@16
|
630 CompletionCondition completion_condition, ReadHandler& handler)
|
Chris@16
|
631 : detail::base_from_completion_cond<
|
Chris@16
|
632 CompletionCondition>(completion_condition),
|
Chris@16
|
633 device_(device),
|
Chris@16
|
634 offset_(offset),
|
Chris@16
|
635 streambuf_(streambuf),
|
Chris@16
|
636 start_(0),
|
Chris@16
|
637 total_transferred_(0),
|
Chris@16
|
638 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
|
Chris@16
|
639 {
|
Chris@16
|
640 }
|
Chris@16
|
641
|
Chris@16
|
642 #if defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
643 read_at_streambuf_op(const read_at_streambuf_op& other)
|
Chris@16
|
644 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
645 device_(other.device_),
|
Chris@16
|
646 offset_(other.offset_),
|
Chris@16
|
647 streambuf_(other.streambuf_),
|
Chris@16
|
648 start_(other.start_),
|
Chris@16
|
649 total_transferred_(other.total_transferred_),
|
Chris@16
|
650 handler_(other.handler_)
|
Chris@16
|
651 {
|
Chris@16
|
652 }
|
Chris@16
|
653
|
Chris@16
|
654 read_at_streambuf_op(read_at_streambuf_op&& other)
|
Chris@16
|
655 : detail::base_from_completion_cond<CompletionCondition>(other),
|
Chris@16
|
656 device_(other.device_),
|
Chris@16
|
657 offset_(other.offset_),
|
Chris@16
|
658 streambuf_(other.streambuf_),
|
Chris@16
|
659 start_(other.start_),
|
Chris@16
|
660 total_transferred_(other.total_transferred_),
|
Chris@16
|
661 handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
|
Chris@16
|
662 {
|
Chris@16
|
663 }
|
Chris@16
|
664 #endif // defined(BOOST_ASIO_HAS_MOVE)
|
Chris@16
|
665
|
Chris@16
|
666 void operator()(const boost::system::error_code& ec,
|
Chris@16
|
667 std::size_t bytes_transferred, int start = 0)
|
Chris@16
|
668 {
|
Chris@16
|
669 std::size_t max_size, bytes_available;
|
Chris@16
|
670 switch (start_ = start)
|
Chris@16
|
671 {
|
Chris@16
|
672 case 1:
|
Chris@16
|
673 max_size = this->check_for_completion(ec, total_transferred_);
|
Chris@16
|
674 bytes_available = read_size_helper(streambuf_, max_size);
|
Chris@16
|
675 for (;;)
|
Chris@16
|
676 {
|
Chris@16
|
677 device_.async_read_some_at(offset_ + total_transferred_,
|
Chris@16
|
678 streambuf_.prepare(bytes_available),
|
Chris@16
|
679 BOOST_ASIO_MOVE_CAST(read_at_streambuf_op)(*this));
|
Chris@16
|
680 return; default:
|
Chris@16
|
681 total_transferred_ += bytes_transferred;
|
Chris@16
|
682 streambuf_.commit(bytes_transferred);
|
Chris@16
|
683 max_size = this->check_for_completion(ec, total_transferred_);
|
Chris@16
|
684 bytes_available = read_size_helper(streambuf_, max_size);
|
Chris@16
|
685 if ((!ec && bytes_transferred == 0) || bytes_available == 0)
|
Chris@16
|
686 break;
|
Chris@16
|
687 }
|
Chris@16
|
688
|
Chris@16
|
689 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
|
Chris@16
|
690 }
|
Chris@16
|
691 }
|
Chris@16
|
692
|
Chris@16
|
693 //private:
|
Chris@16
|
694 AsyncRandomAccessReadDevice& device_;
|
Chris@16
|
695 uint64_t offset_;
|
Chris@16
|
696 boost::asio::basic_streambuf<Allocator>& streambuf_;
|
Chris@16
|
697 int start_;
|
Chris@16
|
698 std::size_t total_transferred_;
|
Chris@16
|
699 ReadHandler handler_;
|
Chris@16
|
700 };
|
Chris@16
|
701
|
Chris@16
|
702 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
703 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
704 inline void* asio_handler_allocate(std::size_t size,
|
Chris@16
|
705 read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
Chris@16
|
706 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
707 {
|
Chris@16
|
708 return boost_asio_handler_alloc_helpers::allocate(
|
Chris@16
|
709 size, this_handler->handler_);
|
Chris@16
|
710 }
|
Chris@16
|
711
|
Chris@16
|
712 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
713 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
714 inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
Chris@16
|
715 read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
Chris@16
|
716 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
717 {
|
Chris@16
|
718 boost_asio_handler_alloc_helpers::deallocate(
|
Chris@16
|
719 pointer, size, this_handler->handler_);
|
Chris@16
|
720 }
|
Chris@16
|
721
|
Chris@16
|
722 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
723 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
724 inline bool asio_handler_is_continuation(
|
Chris@16
|
725 read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
Chris@16
|
726 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
727 {
|
Chris@16
|
728 return this_handler->start_ == 0 ? true
|
Chris@16
|
729 : boost_asio_handler_cont_helpers::is_continuation(
|
Chris@16
|
730 this_handler->handler_);
|
Chris@16
|
731 }
|
Chris@16
|
732
|
Chris@16
|
733 template <typename Function, typename AsyncRandomAccessReadDevice,
|
Chris@16
|
734 typename Allocator, typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
735 inline void asio_handler_invoke(Function& function,
|
Chris@16
|
736 read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
Chris@16
|
737 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
738 {
|
Chris@16
|
739 boost_asio_handler_invoke_helpers::invoke(
|
Chris@16
|
740 function, this_handler->handler_);
|
Chris@16
|
741 }
|
Chris@16
|
742
|
Chris@16
|
743 template <typename Function, typename AsyncRandomAccessReadDevice,
|
Chris@16
|
744 typename Allocator, typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
745 inline void asio_handler_invoke(const Function& function,
|
Chris@16
|
746 read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
Chris@16
|
747 CompletionCondition, ReadHandler>* this_handler)
|
Chris@16
|
748 {
|
Chris@16
|
749 boost_asio_handler_invoke_helpers::invoke(
|
Chris@16
|
750 function, this_handler->handler_);
|
Chris@16
|
751 }
|
Chris@16
|
752 } // namespace detail
|
Chris@16
|
753
|
Chris@16
|
754 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
755 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
756 inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
757 void (boost::system::error_code, std::size_t))
|
Chris@16
|
758 async_read_at(AsyncRandomAccessReadDevice& d,
|
Chris@16
|
759 uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
|
Chris@16
|
760 CompletionCondition completion_condition,
|
Chris@16
|
761 BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
Chris@16
|
762 {
|
Chris@16
|
763 // If you get an error on the following line it means that your handler does
|
Chris@16
|
764 // not meet the documented type requirements for a ReadHandler.
|
Chris@16
|
765 BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
Chris@16
|
766
|
Chris@16
|
767 detail::async_result_init<
|
Chris@16
|
768 ReadHandler, void (boost::system::error_code, std::size_t)> init(
|
Chris@16
|
769 BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
Chris@16
|
770
|
Chris@16
|
771 detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
Chris@16
|
772 CompletionCondition, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
|
Chris@16
|
773 void (boost::system::error_code, std::size_t))>(
|
Chris@16
|
774 d, offset, b, completion_condition, init.handler)(
|
Chris@16
|
775 boost::system::error_code(), 0, 1);
|
Chris@16
|
776
|
Chris@16
|
777 return init.result.get();
|
Chris@16
|
778 }
|
Chris@16
|
779
|
Chris@16
|
780 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
781 typename ReadHandler>
|
Chris@16
|
782 inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
783 void (boost::system::error_code, std::size_t))
|
Chris@16
|
784 async_read_at(AsyncRandomAccessReadDevice& d,
|
Chris@16
|
785 uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
|
Chris@16
|
786 BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
Chris@16
|
787 {
|
Chris@16
|
788 // If you get an error on the following line it means that your handler does
|
Chris@16
|
789 // not meet the documented type requirements for a ReadHandler.
|
Chris@16
|
790 BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
Chris@16
|
791
|
Chris@16
|
792 detail::async_result_init<
|
Chris@16
|
793 ReadHandler, void (boost::system::error_code, std::size_t)> init(
|
Chris@16
|
794 BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
Chris@16
|
795
|
Chris@16
|
796 detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
|
Chris@16
|
797 detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
|
Chris@16
|
798 void (boost::system::error_code, std::size_t))>(
|
Chris@16
|
799 d, offset, b, transfer_all(), init.handler)(
|
Chris@16
|
800 boost::system::error_code(), 0, 1);
|
Chris@16
|
801
|
Chris@16
|
802 return init.result.get();
|
Chris@16
|
803 }
|
Chris@16
|
804
|
Chris@16
|
805 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
806
|
Chris@16
|
807 } // namespace asio
|
Chris@16
|
808 } // namespace boost
|
Chris@16
|
809
|
Chris@16
|
810 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
811
|
Chris@16
|
812 #endif // BOOST_ASIO_IMPL_READ_AT_HPP
|