X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Fasio%2Fread.hpp;h=cb016395ffea916bb48eb68860b51b8b8f99cbee;hb=92f5a8d42d07f9929ae4fa7e01342fe8d96808a8;hp=cffc8477698730a98b56de8ed97a3eb8fa3a0ddf;hpb=a0324939f9d0e1905d5df8f57442f09dc70af83d;p=ceph.git diff --git a/ceph/src/boost/boost/asio/read.hpp b/ceph/src/boost/boost/asio/read.hpp index cffc84776..cb016395f 100644 --- a/ceph/src/boost/boost/asio/read.hpp +++ b/ceph/src/boost/boost/asio/read.hpp @@ -2,7 +2,7 @@ // read.hpp // ~~~~~~~~ // -// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2019 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) @@ -33,8 +33,8 @@ namespace asio { /** * @defgroup read boost::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. */ /*@{*/ @@ -224,6 +224,8 @@ std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers, is_mutable_buffer_sequence::value >::type* = 0); +#if !defined(BOOST_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 @@ -251,11 +253,12 @@ std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers, * s, buffers, * boost::asio::transfer_all()); @endcode */ -template +template std::size_t read(SyncReadStream& s, - BOOST_ASIO_MOVE_ARG(DynamicBuffer) buffers, + BOOST_ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, typename enable_if< - is_dynamic_buffer::type>::value + is_dynamic_buffer_v1::type>::value + && !is_dynamic_buffer_v2::type>::value >::type* = 0); /// Attempt to read a certain amount of data from a stream before returning. @@ -284,12 +287,13 @@ std::size_t read(SyncReadStream& s, * s, buffers, * boost::asio::transfer_all(), ec); @endcode */ -template +template std::size_t read(SyncReadStream& s, - BOOST_ASIO_MOVE_ARG(DynamicBuffer) buffers, + BOOST_ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, boost::system::error_code& ec, typename enable_if< - is_dynamic_buffer::type>::value + is_dynamic_buffer_v1::type>::value + && !is_dynamic_buffer_v2::type>::value >::type* = 0); /// Attempt to read a certain amount of data from a stream before returning. @@ -328,13 +332,14 @@ std::size_t read(SyncReadStream& s, * * @throws boost::system::system_error Thrown on failure. */ -template std::size_t read(SyncReadStream& s, - BOOST_ASIO_MOVE_ARG(DynamicBuffer) buffers, + BOOST_ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, CompletionCondition completion_condition, typename enable_if< - is_dynamic_buffer::type>::value + is_dynamic_buffer_v1::type>::value + && !is_dynamic_buffer_v2::type>::value >::type* = 0); /// Attempt to read a certain amount of data from a stream before returning. @@ -374,13 +379,14 @@ 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 std::size_t read(SyncReadStream& s, - BOOST_ASIO_MOVE_ARG(DynamicBuffer) buffers, + BOOST_ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, CompletionCondition completion_condition, boost::system::error_code& ec, typename enable_if< - is_dynamic_buffer::type>::value + is_dynamic_buffer_v1::type>::value + && !is_dynamic_buffer_v2::type>::value >::type* = 0); #if !defined(BOOST_ASIO_NO_EXTENSIONS) @@ -528,13 +534,169 @@ std::size_t read(SyncReadStream& s, basic_streambuf& b, #endif // !defined(BOOST_ASIO_NO_IOSTREAM) #endif // !defined(BOOST_ASIO_NO_EXTENSIONS) +#endif // !defined(BOOST_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 boost::system::system_error Thrown on failure. + * + * @note This overload is equivalent to calling: + * @code boost::asio::read( + * s, buffers, + * boost::asio::transfer_all()); @endcode + */ +template +std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers, + typename enable_if< + is_dynamic_buffer_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 boost::asio::read( + * s, buffers, + * boost::asio::transfer_all(), ec); @endcode + */ +template +std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers, + boost::system::error_code& ec, + typename enable_if< + is_dynamic_buffer_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 boost::system::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 boost::system::system_error Thrown on failure. + */ +template +std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers, + CompletionCondition completion_condition, + typename enable_if< + is_dynamic_buffer_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 boost::system::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 +std::size_t read(SyncReadStream& s, DynamicBuffer_v2 buffers, + CompletionCondition completion_condition, boost::system::error_code& ec, + typename enable_if< + is_dynamic_buffer_v2::value + >::type* = 0); /*@}*/ /** * @defgroup async_read boost::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. */ /*@{*/ @@ -579,9 +741,9 @@ std::size_t read(SyncReadStream& s, basic_streambuf& 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 - * boost::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 boost::asio::post(). * * @par Example * To read into a single data buffer use the @ref buffer function as follows: @@ -599,11 +761,16 @@ std::size_t read(SyncReadStream& s, basic_streambuf& b, * handler); @endcode */ template -BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, + BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code, + std::size_t)) ReadHandler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE( + typename AsyncReadStream::executor_type)> +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void (boost::system::error_code, std::size_t)) async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, - BOOST_ASIO_MOVE_ARG(ReadHandler) handler, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type), typename enable_if< is_mutable_buffer_sequence::value >::type* = 0); @@ -657,9 +824,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 - * boost::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 boost::asio::post(). * * @par Example * To read into a single data buffer use the @ref buffer function as follows: @@ -671,17 +838,25 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, * buffers in one go, and how to use it with arrays, boost::array or * std::vector. */ -template -BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void (boost::system::error_code, std::size_t)) async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, CompletionCondition completion_condition, - BOOST_ASIO_MOVE_ARG(ReadHandler) handler, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type), typename enable_if< is_mutable_buffer_sequence::value >::type* = 0); +#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1) + /// Start an asynchronous operation to read a certain amount of data from a /// stream. /** @@ -722,9 +897,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 - * boost::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 boost::asio::post(). * * @note This overload is equivalent to calling: * @code boost::asio::async_read( @@ -732,15 +907,21 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, * boost::asio::transfer_all(), * handler); @endcode */ -template -BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void (boost::system::error_code, std::size_t)) async_read(AsyncReadStream& s, - BOOST_ASIO_MOVE_ARG(DynamicBuffer) buffers, - BOOST_ASIO_MOVE_ARG(ReadHandler) handler, + BOOST_ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type), typename enable_if< - is_dynamic_buffer::type>::value + is_dynamic_buffer_v1::type>::value + && !is_dynamic_buffer_v2::type>::value >::type* = 0); /// Start an asynchronous operation to read a certain amount of data from a @@ -797,20 +978,27 @@ 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 - * boost::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 boost::asio::post(). */ -template -BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void (boost::system::error_code, std::size_t)) async_read(AsyncReadStream& s, - BOOST_ASIO_MOVE_ARG(DynamicBuffer) buffers, + BOOST_ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, CompletionCondition completion_condition, - BOOST_ASIO_MOVE_ARG(ReadHandler) handler, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type), typename enable_if< - is_dynamic_buffer::type>::value + is_dynamic_buffer_v1::type>::value + && !is_dynamic_buffer_v2::type>::value >::type* = 0); #if !defined(BOOST_ASIO_NO_EXTENSIONS) @@ -854,9 +1042,9 @@ 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 - * boost::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 boost::asio::post(). * * @note This overload is equivalent to calling: * @code boost::asio::async_read( @@ -864,11 +1052,17 @@ async_read(AsyncReadStream& s, * boost::asio::transfer_all(), * handler); @endcode */ -template -BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void (boost::system::error_code, std::size_t)) async_read(AsyncReadStream& s, basic_streambuf& b, - BOOST_ASIO_MOVE_ARG(ReadHandler) handler); + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type)); /// Start an asynchronous operation to read a certain amount of data from a /// stream. @@ -922,20 +1116,167 @@ async_read(AsyncReadStream& s, basic_streambuf& 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 - * boost::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 boost::asio::post(). */ -template -BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void (boost::system::error_code, std::size_t)) async_read(AsyncReadStream& s, basic_streambuf& b, CompletionCondition completion_condition, - BOOST_ASIO_MOVE_ARG(ReadHandler) handler); + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type)); #endif // !defined(BOOST_ASIO_NO_IOSTREAM) #endif // !defined(BOOST_ASIO_NO_EXTENSIONS) +#endif // !defined(BOOST_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 composed operation. 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 boost::system::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 boost::asio::post(). + * + * @note This overload is equivalent to calling: + * @code boost::asio::async_read( + * s, buffers, + * boost::asio::transfer_all(), + * handler); @endcode + */ +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, + void (boost::system::error_code, std::size_t)) +async_read(AsyncReadStream& s, DynamicBuffer_v2 buffers, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type), + typename enable_if< + is_dynamic_buffer_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 composed operation. 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 boost::system::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 boost::system::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 boost::asio::post(). + */ +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, + void (boost::system::error_code, std::size_t)) +async_read(AsyncReadStream& s, DynamicBuffer_v2 buffers, + CompletionCondition completion_condition, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN( + typename AsyncReadStream::executor_type), + typename enable_if< + is_dynamic_buffer_v2::value + >::type* = 0); /*@}*/