summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/read.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/read.hpp')
-rw-r--r--3rdparty/asio/include/asio/read.hpp611
1 files changed, 526 insertions, 85 deletions
diff --git a/3rdparty/asio/include/asio/read.hpp b/3rdparty/asio/include/asio/read.hpp
index 4839934dbab..3d666adb8d3 100644
--- a/3rdparty/asio/include/asio/read.hpp
+++ b/3rdparty/asio/include/asio/read.hpp
@@ -2,7 +2,7 @@
// read.hpp
// ~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -32,8 +32,8 @@ namespace asio {
/**
* @defgroup read asio::read
*
- * @brief Attempt to read a certain amount of data from a stream before
- * returning.
+ * @brief The @c read function is a composed operation that reads a certain
+ * amount of data from a stream before returning.
*/
/*@{*/
@@ -75,9 +75,9 @@ namespace asio {
*/
template <typename SyncReadStream, typename MutableBufferSequence>
std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
- typename enable_if<
+ typename constraint<
is_mutable_buffer_sequence<MutableBufferSequence>::value
- >::type* = 0);
+ >::type = 0);
/// Attempt to read a certain amount of data from a stream before returning.
/**
@@ -118,9 +118,9 @@ std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
template <typename SyncReadStream, typename MutableBufferSequence>
std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
asio::error_code& ec,
- typename enable_if<
+ typename constraint<
is_mutable_buffer_sequence<MutableBufferSequence>::value
- >::type* = 0);
+ >::type = 0);
/// Attempt to read a certain amount of data from a stream before returning.
/**
@@ -172,9 +172,9 @@ template <typename SyncReadStream, typename MutableBufferSequence,
typename CompletionCondition>
std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
CompletionCondition completion_condition,
- typename enable_if<
+ typename constraint<
is_mutable_buffer_sequence<MutableBufferSequence>::value
- >::type* = 0);
+ >::type = 0);
/// Attempt to read a certain amount of data from a stream before returning.
/**
@@ -219,9 +219,11 @@ template <typename SyncReadStream, typename MutableBufferSequence,
typename CompletionCondition>
std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
CompletionCondition completion_condition, asio::error_code& ec,
- typename enable_if<
+ typename constraint<
is_mutable_buffer_sequence<MutableBufferSequence>::value
- >::type* = 0);
+ >::type = 0);
+
+#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
/// Attempt to read a certain amount of data from a stream before returning.
/**
@@ -250,12 +252,15 @@ std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
* s, buffers,
* asio::transfer_all()); @endcode
*/
-template <typename SyncReadStream, typename DynamicBuffer>
+template <typename SyncReadStream, typename DynamicBuffer_v1>
std::size_t read(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer) buffers,
- typename enable_if<
- is_dynamic_buffer<DynamicBuffer>::value
- >::type* = 0);
+ ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ typename constraint<
+ is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0,
+ typename constraint<
+ !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0);
/// Attempt to read a certain amount of data from a stream before returning.
/**
@@ -283,13 +288,16 @@ std::size_t read(SyncReadStream& s,
* s, buffers,
* asio::transfer_all(), ec); @endcode
*/
-template <typename SyncReadStream, typename DynamicBuffer>
+template <typename SyncReadStream, typename DynamicBuffer_v1>
std::size_t read(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer) buffers,
+ ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
asio::error_code& ec,
- typename enable_if<
- is_dynamic_buffer<DynamicBuffer>::value
- >::type* = 0);
+ typename constraint<
+ is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0,
+ typename constraint<
+ !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0);
/// Attempt to read a certain amount of data from a stream before returning.
/**
@@ -327,14 +335,17 @@ std::size_t read(SyncReadStream& s,
*
* @throws asio::system_error Thrown on failure.
*/
-template <typename SyncReadStream, typename DynamicBuffer,
+template <typename SyncReadStream, typename DynamicBuffer_v1,
typename CompletionCondition>
std::size_t read(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer) buffers,
+ ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
CompletionCondition completion_condition,
- typename enable_if<
- is_dynamic_buffer<DynamicBuffer>::value
- >::type* = 0);
+ typename constraint<
+ is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0,
+ typename constraint<
+ !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0);
/// Attempt to read a certain amount of data from a stream before returning.
/**
@@ -373,14 +384,17 @@ std::size_t read(SyncReadStream& s,
* @returns The number of bytes read. If an error occurs, returns the total
* number of bytes successfully transferred prior to the error.
*/
-template <typename SyncReadStream, typename DynamicBuffer,
+template <typename SyncReadStream, typename DynamicBuffer_v1,
typename CompletionCondition>
std::size_t read(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer) buffers,
+ ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
CompletionCondition completion_condition, asio::error_code& ec,
- typename enable_if<
- is_dynamic_buffer<DynamicBuffer>::value
- >::type* = 0);
+ typename constraint<
+ is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0,
+ typename constraint<
+ !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0);
#if !defined(ASIO_NO_EXTENSIONS)
#if !defined(ASIO_NO_IOSTREAM)
@@ -527,13 +541,169 @@ std::size_t read(SyncReadStream& s, basic_streambuf<Allocator>& b,
#endif // !defined(ASIO_NO_IOSTREAM)
#endif // !defined(ASIO_NO_EXTENSIONS)
+#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
+
+/// Attempt to read a certain amount of data from a stream before returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * stream. The call will block until one of the following conditions is true:
+ *
+ * @li The specified dynamic buffer sequence is full (that is, it has reached
+ * maximum size).
+ *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * read_some function.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the SyncReadStream concept.
+ *
+ * @param buffers The dynamic buffer sequence into which the data will be read.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @throws asio::system_error Thrown on failure.
+ *
+ * @note This overload is equivalent to calling:
+ * @code asio::read(
+ * s, buffers,
+ * asio::transfer_all()); @endcode
+ */
+template <typename SyncReadStream, typename DynamicBuffer_v2>
+std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers,
+ typename constraint<
+ is_dynamic_buffer_v2<DynamicBuffer_v2>::value
+ >::type = 0);
+
+/// Attempt to read a certain amount of data from a stream before returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * stream. The call will block until one of the following conditions is true:
+ *
+ * @li The supplied buffer is full (that is, it has reached maximum size).
+ *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * read_some function.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the SyncReadStream concept.
+ *
+ * @param buffers The dynamic buffer sequence into which the data will be read.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @note This overload is equivalent to calling:
+ * @code asio::read(
+ * s, buffers,
+ * asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncReadStream, typename DynamicBuffer_v2>
+std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers,
+ asio::error_code& ec,
+ typename constraint<
+ is_dynamic_buffer_v2<DynamicBuffer_v2>::value
+ >::type = 0);
+
+/// Attempt to read a certain amount of data from a stream before returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * stream. The call will block until one of the following conditions is true:
+ *
+ * @li The specified dynamic buffer sequence is full (that is, it has reached
+ * maximum size).
+ *
+ * @li The completion_condition function object returns 0.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * read_some function.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the SyncReadStream concept.
+ *
+ * @param buffers The dynamic buffer sequence into which the data will be read.
+ *
+ * @param completion_condition The function object to be called to determine
+ * whether the read operation is complete. The signature of the function object
+ * must be:
+ * @code std::size_t completion_condition(
+ * // Result of latest read_some operation.
+ * const asio::error_code& error,
+ *
+ * // Number of bytes transferred so far.
+ * std::size_t bytes_transferred
+ * ); @endcode
+ * A return value of 0 indicates that the read operation is complete. A non-zero
+ * return value indicates the maximum number of bytes to be read on the next
+ * call to the stream's read_some function.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @throws asio::system_error Thrown on failure.
+ */
+template <typename SyncReadStream, typename DynamicBuffer_v2,
+ typename CompletionCondition>
+std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers,
+ CompletionCondition completion_condition,
+ typename constraint<
+ is_dynamic_buffer_v2<DynamicBuffer_v2>::value
+ >::type = 0);
+
+/// Attempt to read a certain amount of data from a stream before returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * stream. The call will block until one of the following conditions is true:
+ *
+ * @li The specified dynamic buffer sequence is full (that is, it has reached
+ * maximum size).
+ *
+ * @li The completion_condition function object returns 0.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * read_some function.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the SyncReadStream concept.
+ *
+ * @param buffers The dynamic buffer sequence into which the data will be read.
+ *
+ * @param completion_condition The function object to be called to determine
+ * whether the read operation is complete. The signature of the function object
+ * must be:
+ * @code std::size_t completion_condition(
+ * // Result of latest read_some operation.
+ * const asio::error_code& error,
+ *
+ * // Number of bytes transferred so far.
+ * std::size_t bytes_transferred
+ * ); @endcode
+ * A return value of 0 indicates that the read operation is complete. A non-zero
+ * return value indicates the maximum number of bytes to be read on the next
+ * call to the stream's read_some function.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes read. If an error occurs, returns the total
+ * number of bytes successfully transferred prior to the error.
+ */
+template <typename SyncReadStream, typename DynamicBuffer_v2,
+ typename CompletionCondition>
+std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers,
+ CompletionCondition completion_condition, asio::error_code& ec,
+ typename constraint<
+ is_dynamic_buffer_v2<DynamicBuffer_v2>::value
+ >::type = 0);
/*@}*/
/**
* @defgroup async_read asio::async_read
*
- * @brief Start an asynchronous operation to read a certain amount of data from
- * a stream.
+ * @brief The @c async_read function is a composed asynchronous operation that
+ * reads a certain amount of data from a stream before completion.
*/
/*@{*/
@@ -578,9 +748,9 @@ std::size_t read(SyncReadStream& s, basic_streambuf<Allocator>& b,
* // prior to the error.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. Invocation of
- * the handler will be performed in a manner equivalent to using
- * asio::io_context::post().
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
@@ -596,16 +766,32 @@ std::size_t read(SyncReadStream& s, basic_streambuf<Allocator>& b,
* s, buffers,
* asio::transfer_all(),
* handler); @endcode
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
*/
template <typename AsyncReadStream, typename MutableBufferSequence,
- typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
void (asio::error_code, std::size_t))
async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
- ASIO_MOVE_ARG(ReadHandler) handler,
- typename enable_if<
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type),
+ typename constraint<
is_mutable_buffer_sequence<MutableBufferSequence>::value
- >::type* = 0);
+ >::type = 0);
/// Start an asynchronous operation to read a certain amount of data from a
/// stream.
@@ -656,9 +842,9 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
* // prior to the error.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. Invocation of
- * the handler will be performed in a manner equivalent to using
- * asio::io_context::post().
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
@@ -669,17 +855,36 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
* See the @ref buffer documentation for information on reading into multiple
* buffers in one go, and how to use it with arrays, boost::array or
* std::vector.
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
*/
-template <typename AsyncReadStream, typename MutableBufferSequence,
- typename CompletionCondition, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
+template <typename AsyncReadStream,
+ typename MutableBufferSequence, typename CompletionCondition,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
void (asio::error_code, std::size_t))
async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
CompletionCondition completion_condition,
- ASIO_MOVE_ARG(ReadHandler) handler,
- typename enable_if<
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type),
+ typename constraint<
is_mutable_buffer_sequence<MutableBufferSequence>::value
- >::type* = 0);
+ >::type = 0);
+
+#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
/// Start an asynchronous operation to read a certain amount of data from a
/// stream.
@@ -721,26 +926,45 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
* // prior to the error.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. Invocation of
- * the handler will be performed in a manner equivalent to using
- * asio::io_context::post().
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
*
* @note This overload is equivalent to calling:
* @code asio::async_read(
* s, buffers,
* asio::transfer_all(),
* handler); @endcode
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
*/
-template <typename AsyncReadStream,
- typename DynamicBuffer, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
+template <typename AsyncReadStream, typename DynamicBuffer_v1,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
void (asio::error_code, std::size_t))
async_read(AsyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer) buffers,
- ASIO_MOVE_ARG(ReadHandler) handler,
- typename enable_if<
- is_dynamic_buffer<DynamicBuffer>::value
- >::type* = 0);
+ ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type),
+ typename constraint<
+ is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0,
+ typename constraint<
+ !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0);
/// Start an asynchronous operation to read a certain amount of data from a
/// stream.
@@ -796,21 +1020,41 @@ async_read(AsyncReadStream& s,
* // prior to the error.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. Invocation of
- * the handler will be performed in a manner equivalent to using
- * asio::io_context::post().
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
*/
-template <typename AsyncReadStream, typename DynamicBuffer,
- typename CompletionCondition, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
+template <typename AsyncReadStream,
+ typename DynamicBuffer_v1, typename CompletionCondition,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
void (asio::error_code, std::size_t))
async_read(AsyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer) buffers,
+ ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
CompletionCondition completion_condition,
- ASIO_MOVE_ARG(ReadHandler) handler,
- typename enable_if<
- is_dynamic_buffer<DynamicBuffer>::value
- >::type* = 0);
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type),
+ typename constraint<
+ is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0,
+ typename constraint<
+ !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
+ >::type = 0);
#if !defined(ASIO_NO_EXTENSIONS)
#if !defined(ASIO_NO_IOSTREAM)
@@ -853,21 +1097,38 @@ async_read(AsyncReadStream& s,
* // prior to the error.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. Invocation of
- * the handler will be performed in a manner equivalent to using
- * asio::io_context::post().
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
*
* @note This overload is equivalent to calling:
* @code asio::async_read(
* s, b,
* asio::transfer_all(),
* handler); @endcode
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
*/
-template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
+template <typename AsyncReadStream, typename Allocator,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
void (asio::error_code, std::size_t))
async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
- ASIO_MOVE_ARG(ReadHandler) handler);
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type));
/// Start an asynchronous operation to read a certain amount of data from a
/// stream.
@@ -921,20 +1182,200 @@ async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
* // prior to the error.
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. Invocation of
- * the handler will be performed in a manner equivalent to using
- * asio::io_context::post().
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
*/
-template <typename AsyncReadStream, typename Allocator,
- typename CompletionCondition, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
+template <typename AsyncReadStream,
+ typename Allocator, typename CompletionCondition,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
void (asio::error_code, std::size_t))
async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
CompletionCondition completion_condition,
- ASIO_MOVE_ARG(ReadHandler) handler);
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type));
#endif // !defined(ASIO_NO_IOSTREAM)
#endif // !defined(ASIO_NO_EXTENSIONS)
+#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
+
+/// Start an asynchronous operation to read a certain amount of data from a
+/// stream.
+/**
+ * This function is used to asynchronously read a certain number of bytes of
+ * data from a stream. The function call always returns immediately. The
+ * asynchronous operation will continue until one of the following conditions is
+ * true:
+ *
+ * @li The specified dynamic buffer sequence is full (that is, it has reached
+ * maximum size).
+ *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * async_read_some function, and is known as a <em>composed operation</em>. The
+ * program must ensure that the stream performs no other read operations (such
+ * as async_read, the stream's async_read_some function, or any other composed
+ * operations that perform reads) until this operation completes.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the AsyncReadStream concept.
+ *
+ * @param buffers The dynamic buffer sequence into which the data will be read.
+ * Although the buffers object may be copied as necessary, ownership of the
+ * underlying memory blocks is retained by the caller, which must guarantee
+ * that they remain valid until the handler is called.
+ *
+ * @param handler The handler to be called when the read operation completes.
+ * Copies will be made of the handler as required. The function signature of the
+ * handler must be:
+ * @code void handler(
+ * const asio::error_code& error, // Result of operation.
+ *
+ * std::size_t bytes_transferred // Number of bytes copied into the
+ * // buffers. If an error occurred,
+ * // this will be the number of
+ * // bytes successfully transferred
+ * // prior to the error.
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
+ *
+ * @note This overload is equivalent to calling:
+ * @code asio::async_read(
+ * s, buffers,
+ * asio::transfer_all(),
+ * handler); @endcode
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
+ */
+template <typename AsyncReadStream, typename DynamicBuffer_v2,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
+ void (asio::error_code, std::size_t))
+async_read(AsyncReadStream& s, DynamicBuffer_v2 buffers,
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type),
+ typename constraint<
+ is_dynamic_buffer_v2<DynamicBuffer_v2>::value
+ >::type = 0);
+
+/// Start an asynchronous operation to read a certain amount of data from a
+/// stream.
+/**
+ * This function is used to asynchronously read a certain number of bytes of
+ * data from a stream. The function call always returns immediately. The
+ * asynchronous operation will continue until one of the following conditions is
+ * true:
+ *
+ * @li The specified dynamic buffer sequence is full (that is, it has reached
+ * maximum size).
+ *
+ * @li The completion_condition function object returns 0.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * async_read_some function, and is known as a <em>composed operation</em>. The
+ * program must ensure that the stream performs no other read operations (such
+ * as async_read, the stream's async_read_some function, or any other composed
+ * operations that perform reads) until this operation completes.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the AsyncReadStream concept.
+ *
+ * @param buffers The dynamic buffer sequence into which the data will be read.
+ * Although the buffers object may be copied as necessary, ownership of the
+ * underlying memory blocks is retained by the caller, which must guarantee
+ * that they remain valid until the handler is called.
+ *
+ * @param completion_condition The function object to be called to determine
+ * whether the read operation is complete. The signature of the function object
+ * must be:
+ * @code std::size_t completion_condition(
+ * // Result of latest async_read_some operation.
+ * const asio::error_code& error,
+ *
+ * // Number of bytes transferred so far.
+ * std::size_t bytes_transferred
+ * ); @endcode
+ * A return value of 0 indicates that the read operation is complete. A non-zero
+ * return value indicates the maximum number of bytes to be read on the next
+ * call to the stream's async_read_some function.
+ *
+ * @param handler The handler to be called when the read operation completes.
+ * Copies will be made of the handler as required. The function signature of the
+ * handler must be:
+ * @code void handler(
+ * const asio::error_code& error, // Result of operation.
+ *
+ * std::size_t bytes_transferred // Number of bytes copied into the
+ * // buffers. If an error occurred,
+ * // this will be the number of
+ * // bytes successfully transferred
+ * // prior to the error.
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. On
+ * immediate completion, invocation of the handler will be performed in a
+ * manner equivalent to using asio::post().
+ *
+ * @par Per-Operation Cancellation
+ * This asynchronous operation supports cancellation for the following
+ * asio::cancellation_type values:
+ *
+ * @li @c cancellation_type::terminal
+ *
+ * @li @c cancellation_type::partial
+ *
+ * if they are also supported by the @c AsyncReadStream type's
+ * @c async_read_some operation.
+ */
+template <typename AsyncReadStream,
+ typename DynamicBuffer_v2, typename CompletionCondition,
+ ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
+ std::size_t)) ReadHandler
+ ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+ typename AsyncReadStream::executor_type)>
+ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
+ void (asio::error_code, std::size_t))
+async_read(AsyncReadStream& s, DynamicBuffer_v2 buffers,
+ CompletionCondition completion_condition,
+ ASIO_MOVE_ARG(ReadHandler) handler
+ ASIO_DEFAULT_COMPLETION_TOKEN(
+ typename AsyncReadStream::executor_type),
+ typename constraint<
+ is_dynamic_buffer_v2<DynamicBuffer_v2>::value
+ >::type = 0);
/*@}*/