update boost
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// posix/basic_descriptor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2023 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)
|
||||
@@ -20,17 +20,22 @@
|
||||
#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <boost/asio/any_io_executor.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/io_object_impl.hpp>
|
||||
#include <boost/asio/detail/non_const_lvalue.hpp>
|
||||
#include <boost/asio/detail/reactive_descriptor_service.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/execution_context.hpp>
|
||||
#include <boost/asio/executor.hpp>
|
||||
#include <boost/asio/posix/descriptor_base.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
# include <boost/asio/detail/io_uring_descriptor_service.hpp>
|
||||
#else // defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
# include <boost/asio/detail/reactive_descriptor_service.hpp>
|
||||
#endif // defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
# include <utility>
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
@@ -50,21 +55,35 @@ namespace posix {
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename Executor = executor>
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_descriptor
|
||||
: public descriptor_base
|
||||
{
|
||||
private:
|
||||
class initiate_async_wait;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the descriptor type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The descriptor type when rebound to the specified executor.
|
||||
typedef basic_descriptor<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a descriptor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
#elif defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
typedef detail::io_uring_descriptor_service::native_handle_type
|
||||
native_handle_type;
|
||||
#else // defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
typedef detail::reactive_descriptor_service::native_handle_type
|
||||
native_handle_type;
|
||||
#endif
|
||||
#endif // defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
|
||||
/// A descriptor is always the lowest layer.
|
||||
typedef basic_descriptor lowest_layer_type;
|
||||
@@ -78,7 +97,7 @@ public:
|
||||
* descriptor.
|
||||
*/
|
||||
explicit basic_descriptor(const executor_type& ex)
|
||||
: impl_(ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -92,10 +111,11 @@ public:
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_descriptor(ExecutionContext& context,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
: impl_(context)
|
||||
typename constraint<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint())
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -114,7 +134,7 @@ public:
|
||||
*/
|
||||
basic_descriptor(const executor_type& ex,
|
||||
const native_handle_type& native_descriptor)
|
||||
: impl_(ex)
|
||||
: impl_(0, ex)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
@@ -138,10 +158,10 @@ public:
|
||||
template <typename ExecutionContext>
|
||||
basic_descriptor(ExecutionContext& context,
|
||||
const native_handle_type& native_descriptor,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
: impl_(context)
|
||||
>::type = 0)
|
||||
: impl_(0, 0, context)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
impl_.get_service().assign(impl_.get_implementation(),
|
||||
@@ -161,7 +181,7 @@ public:
|
||||
* constructed using the @c basic_descriptor(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_descriptor(basic_descriptor&& other)
|
||||
basic_descriptor(basic_descriptor&& other) BOOST_ASIO_NOEXCEPT
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
@@ -182,10 +202,58 @@ public:
|
||||
impl_ = std::move(other.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// All descriptors have access to each other's implementations.
|
||||
template <typename Executor1>
|
||||
friend class basic_descriptor;
|
||||
|
||||
/// Move-construct a basic_descriptor from a descriptor of another executor
|
||||
/// type.
|
||||
/**
|
||||
* This constructor moves a descriptor from one object to another.
|
||||
*
|
||||
* @param other The other basic_descriptor object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_descriptor(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_descriptor(basic_descriptor<Executor1>&& other,
|
||||
typename constraint<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint())
|
||||
: impl_(std::move(other.impl_))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_descriptor from a descriptor of another executor type.
|
||||
/**
|
||||
* This assignment operator moves a descriptor from one object to another.
|
||||
*
|
||||
* @param other The other basic_descriptor object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_descriptor(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
typename constraint<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_descriptor&
|
||||
>::type operator=(basic_descriptor<Executor1> && other)
|
||||
{
|
||||
basic_descriptor tmp(std::move(other));
|
||||
impl_ = std::move(tmp.impl_);
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Get the executor associated with the object.
|
||||
executor_type get_executor() BOOST_ASIO_NOEXCEPT
|
||||
const executor_type& get_executor() BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return impl_.get_executor();
|
||||
}
|
||||
@@ -581,21 +649,28 @@ public:
|
||||
/// write, or to have pending error conditions.
|
||||
/**
|
||||
* This function is used to perform an asynchronous wait for a descriptor to
|
||||
* enter a ready to read, write or error condition state.
|
||||
* enter a ready to read, write or error condition state. It is an initiating
|
||||
* function for an @ref asynchronous_operation, and always returns
|
||||
* immediately.
|
||||
*
|
||||
* @param w Specifies the desired descriptor state.
|
||||
*
|
||||
* @param handler The handler to be called when the wait operation completes.
|
||||
* Copies will be made of the handler as required. The function signature of
|
||||
* the handler must be:
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the wait completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error // Result of operation
|
||||
* const boost::system::error_code& error // Result of operation.
|
||||
* ); @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
|
||||
* not, the completion 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 Completion Signature
|
||||
* @code void(boost::system::error_code) @endcode
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
* void wait_handler(const boost::system::error_code& error)
|
||||
@@ -614,14 +689,31 @@ public:
|
||||
* boost::asio::posix::stream_descriptor::wait_read,
|
||||
* wait_handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Per-Operation Cancellation
|
||||
* This asynchronous operation supports cancellation for the following
|
||||
* boost::asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename WaitHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
|
||||
template <
|
||||
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code))
|
||||
WaitToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
|
||||
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WaitToken,
|
||||
void (boost::system::error_code))
|
||||
async_wait(wait_type w, BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
|
||||
async_wait(wait_type w,
|
||||
BOOST_ASIO_MOVE_ARG(WaitToken) token
|
||||
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
|
||||
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WaitToken, void (boost::system::error_code)>(
|
||||
declval<initiate_async_wait>(), token, w)))
|
||||
{
|
||||
return async_initiate<WaitHandler, void (boost::system::error_code)>(
|
||||
initiate_async_wait(), handler, this, w);
|
||||
return async_initiate<WaitToken, void (boost::system::error_code)>(
|
||||
initiate_async_wait(this), token, w);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -635,28 +727,47 @@ protected:
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
detail::io_object_impl<detail::io_uring_descriptor_service, Executor> impl_;
|
||||
#else // defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
detail::io_object_impl<detail::reactive_descriptor_service, Executor> impl_;
|
||||
#endif // defined(BOOST_ASIO_HAS_IO_URING_AS_DEFAULT)
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
basic_descriptor(const basic_descriptor&) BOOST_ASIO_DELETED;
|
||||
basic_descriptor& operator=(const basic_descriptor&) BOOST_ASIO_DELETED;
|
||||
|
||||
struct initiate_async_wait
|
||||
class initiate_async_wait
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_wait(basic_descriptor* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WaitHandler>
|
||||
void operator()(BOOST_ASIO_MOVE_ARG(WaitHandler) handler,
|
||||
basic_descriptor* self, wait_type w) const
|
||||
void operator()(BOOST_ASIO_MOVE_ARG(WaitHandler) handler, wait_type w) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
// does not meet the documented type requirements for a WaitHandler.
|
||||
BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WaitHandler> handler2(handler);
|
||||
self->impl_.get_service().async_wait(
|
||||
self->impl_.get_implementation(), w, handler2.value,
|
||||
self->impl_.get_implementation_executor());
|
||||
self_->impl_.get_service().async_wait(
|
||||
self_->impl_.get_implementation(), w,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_descriptor* self_;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// posix/basic_stream_descriptor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2023 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)
|
||||
@@ -16,11 +16,13 @@
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/posix/descriptor.hpp>
|
||||
#include <boost/asio/posix/basic_descriptor.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace posix {
|
||||
@@ -34,17 +36,35 @@ namespace posix {
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* Synchronous @c read_some and @c write_some operations are thread safe with
|
||||
* respect to each other, if the underlying operating system calls are also
|
||||
* thread safe. This means that it is permitted to perform concurrent calls to
|
||||
* these synchronous operations on a single descriptor object. Other synchronous
|
||||
* operations, such as @c close, are not thread safe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Executor = executor>
|
||||
template <typename Executor = any_io_executor>
|
||||
class basic_stream_descriptor
|
||||
: public basic_descriptor<Executor>
|
||||
{
|
||||
private:
|
||||
class initiate_async_write_some;
|
||||
class initiate_async_read_some;
|
||||
|
||||
public:
|
||||
/// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
/// Rebinds the descriptor type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
/// The descriptor type when rebound to the specified executor.
|
||||
typedef basic_stream_descriptor<Executor1> other;
|
||||
};
|
||||
|
||||
/// The native representation of a descriptor.
|
||||
typedef typename basic_descriptor<Executor>::native_handle_type
|
||||
native_handle_type;
|
||||
@@ -76,9 +96,10 @@ public:
|
||||
*/
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_stream_descriptor(ExecutionContext& context,
|
||||
typename enable_if<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
typename constraint<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint())
|
||||
: basic_descriptor<Executor>(context)
|
||||
{
|
||||
}
|
||||
@@ -118,9 +139,9 @@ public:
|
||||
template <typename ExecutionContext>
|
||||
basic_stream_descriptor(ExecutionContext& context,
|
||||
const native_handle_type& native_descriptor,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
is_convertible<ExecutionContext&, execution_context&>::value
|
||||
>::type* = 0)
|
||||
>::type = 0)
|
||||
: basic_descriptor<Executor>(context, native_descriptor)
|
||||
{
|
||||
}
|
||||
@@ -137,8 +158,8 @@ public:
|
||||
* constructed using the @c basic_stream_descriptor(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
basic_stream_descriptor(basic_stream_descriptor&& other)
|
||||
: descriptor(std::move(other))
|
||||
basic_stream_descriptor(basic_stream_descriptor&& other) BOOST_ASIO_NOEXCEPT
|
||||
: basic_descriptor<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -156,7 +177,51 @@ public:
|
||||
*/
|
||||
basic_stream_descriptor& operator=(basic_stream_descriptor&& other)
|
||||
{
|
||||
descriptor::operator=(std::move(other));
|
||||
basic_descriptor<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Move-construct a basic_stream_descriptor from a descriptor of another
|
||||
/// executor type.
|
||||
/**
|
||||
* This constructor moves a descriptor from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_descriptor object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_descriptor(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
basic_stream_descriptor(basic_stream_descriptor<Executor1>&& other,
|
||||
typename constraint<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint())
|
||||
: basic_descriptor<Executor>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_stream_descriptor from a descriptor of another
|
||||
/// executor type.
|
||||
/**
|
||||
* This assignment operator moves a descriptor from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_descriptor object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_descriptor(const executor_type&)
|
||||
* constructor.
|
||||
*/
|
||||
template <typename Executor1>
|
||||
typename constraint<
|
||||
is_convertible<Executor1, Executor>::value,
|
||||
basic_stream_descriptor&
|
||||
>::type operator=(basic_stream_descriptor<Executor1> && other)
|
||||
{
|
||||
basic_descriptor<Executor>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
@@ -225,25 +290,31 @@ public:
|
||||
/// Start an asynchronous write.
|
||||
/**
|
||||
* This function is used to asynchronously write data to the stream
|
||||
* descriptor. The function call always returns immediately.
|
||||
* descriptor. It is an initiating function for an @ref
|
||||
* asynchronous_operation, and always returns immediately.
|
||||
*
|
||||
* @param buffers One or more data buffers to be written to the descriptor.
|
||||
* 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.
|
||||
* that they remain valid until the completion handler is called.
|
||||
*
|
||||
* @param handler The handler to be called when the write operation completes.
|
||||
* Copies will be made of the handler as required. The function signature of
|
||||
* the handler must be:
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the write completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* std::size_t bytes_transferred // Number of bytes written.
|
||||
* ); @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
|
||||
* not, the completion 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 Completion Signature
|
||||
* @code void(boost::system::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The write operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref async_write function if you need to ensure that all
|
||||
* data is written before the asynchronous operation completes.
|
||||
@@ -256,16 +327,34 @@ public:
|
||||
* See the @ref buffer documentation for information on writing 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
|
||||
* boost::asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
|
||||
template <typename ConstBufferSequence,
|
||||
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
|
||||
std::size_t)) WriteToken
|
||||
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
|
||||
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(WriteToken,
|
||||
void (boost::system::error_code, std::size_t))
|
||||
async_write_some(const ConstBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
BOOST_ASIO_MOVE_ARG(WriteToken) token
|
||||
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
|
||||
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<WriteToken,
|
||||
void (boost::system::error_code, std::size_t)>(
|
||||
initiate_async_write_some(this), token, buffers)))
|
||||
{
|
||||
return async_initiate<WriteHandler,
|
||||
return async_initiate<WriteToken,
|
||||
void (boost::system::error_code, std::size_t)>(
|
||||
initiate_async_write_some(), handler, this, buffers);
|
||||
initiate_async_write_some(this), token, buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the descriptor.
|
||||
@@ -334,25 +423,31 @@ public:
|
||||
/// Start an asynchronous read.
|
||||
/**
|
||||
* This function is used to asynchronously read data from the stream
|
||||
* descriptor. The function call always returns immediately.
|
||||
* descriptor. It is an initiating function for an @ref
|
||||
* asynchronous_operation, and always returns immediately.
|
||||
*
|
||||
* @param buffers One or more buffers 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.
|
||||
* that they remain valid until the completion 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:
|
||||
* @param token The @ref completion_token that will be used to produce a
|
||||
* completion handler, which will be called when the read completes.
|
||||
* Potential completion tokens include @ref use_future, @ref use_awaitable,
|
||||
* @ref yield_context, or a function object with the correct completion
|
||||
* signature. The function signature of the completion handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* std::size_t bytes_transferred // Number of bytes read.
|
||||
* ); @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
|
||||
* not, the completion 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 Completion Signature
|
||||
* @code void(boost::system::error_code, std::size_t) @endcode
|
||||
*
|
||||
* @note The read operation may not read all of the requested number of bytes.
|
||||
* Consider using the @ref async_read function if you need to ensure that the
|
||||
* requested amount of data is read before the asynchronous operation
|
||||
@@ -366,24 +461,54 @@ public:
|
||||
* 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
|
||||
* boost::asio::cancellation_type values:
|
||||
*
|
||||
* @li @c cancellation_type::terminal
|
||||
*
|
||||
* @li @c cancellation_type::partial
|
||||
*
|
||||
* @li @c cancellation_type::total
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
||||
template <typename MutableBufferSequence,
|
||||
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
|
||||
std::size_t)) ReadToken
|
||||
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
|
||||
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(ReadToken,
|
||||
void (boost::system::error_code, std::size_t))
|
||||
async_read_some(const MutableBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
BOOST_ASIO_MOVE_ARG(ReadToken) token
|
||||
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
|
||||
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX((
|
||||
async_initiate<ReadToken,
|
||||
void (boost::system::error_code, std::size_t)>(
|
||||
declval<initiate_async_read_some>(), token, buffers)))
|
||||
{
|
||||
return async_initiate<ReadHandler,
|
||||
return async_initiate<ReadToken,
|
||||
void (boost::system::error_code, std::size_t)>(
|
||||
initiate_async_read_some(), handler, this, buffers);
|
||||
initiate_async_read_some(this), token, buffers);
|
||||
}
|
||||
|
||||
private:
|
||||
struct initiate_async_write_some
|
||||
class initiate_async_write_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_write_some(basic_stream_descriptor* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename WriteHandler, typename ConstBufferSequence>
|
||||
void operator()(BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
|
||||
basic_stream_descriptor* self,
|
||||
const ConstBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
@@ -391,17 +516,32 @@ private:
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<WriteHandler> handler2(handler);
|
||||
self->impl_.get_service().async_write_some(
|
||||
self->impl_.get_implementation(), buffers, handler2.value,
|
||||
self->impl_.get_implementation_executor());
|
||||
self_->impl_.get_service().async_write_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_stream_descriptor* self_;
|
||||
};
|
||||
|
||||
struct initiate_async_read_some
|
||||
class initiate_async_read_some
|
||||
{
|
||||
public:
|
||||
typedef Executor executor_type;
|
||||
|
||||
explicit initiate_async_read_some(basic_stream_descriptor* self)
|
||||
: self_(self)
|
||||
{
|
||||
}
|
||||
|
||||
const executor_type& get_executor() const BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return self_->get_executor();
|
||||
}
|
||||
|
||||
template <typename ReadHandler, typename MutableBufferSequence>
|
||||
void operator()(BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
|
||||
basic_stream_descriptor* self,
|
||||
const MutableBufferSequence& buffers) const
|
||||
{
|
||||
// If you get an error on the following line it means that your handler
|
||||
@@ -409,10 +549,13 @@ private:
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
detail::non_const_lvalue<ReadHandler> handler2(handler);
|
||||
self->impl_.get_service().async_read_some(
|
||||
self->impl_.get_implementation(), buffers, handler2.value,
|
||||
self->impl_.get_implementation_executor());
|
||||
self_->impl_.get_service().async_read_some(
|
||||
self_->impl_.get_implementation(), buffers,
|
||||
handler2.value, self_->impl_.get_executor());
|
||||
}
|
||||
|
||||
private:
|
||||
basic_stream_descriptor* self_;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -420,6 +563,8 @@ private:
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// posix/descriptor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2023 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)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// posix/descriptor_base.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2023 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)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// posix/stream_descriptor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2023 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)
|
||||
|
||||
Reference in New Issue
Block a user