update boost

This commit is contained in:
2023-11-24 12:56:13 -06:00
parent cfc99971af
commit 19d727037a
9260 changed files with 849256 additions and 299957 deletions

View File

@@ -2,7 +2,7 @@
// basic_waitable_timer.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)
@@ -17,6 +17,7 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/asio/any_io_executor.hpp>
#include <boost/asio/detail/chrono_time_traits.hpp>
#include <boost/asio/detail/deadline_timer_service.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
@@ -24,7 +25,6 @@
#include <boost/asio/detail/non_const_lvalue.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/executor.hpp>
#include <boost/asio/wait_traits.hpp>
#if defined(BOOST_ASIO_HAS_MOVE)
@@ -42,7 +42,7 @@ namespace asio {
// Forward declaration with defaulted arguments.
template <typename Clock,
typename WaitTraits = boost::asio::wait_traits<Clock>,
typename Executor = executor>
typename Executor = any_io_executor>
class basic_waitable_timer;
#endif // !defined(BOOST_ASIO_BASIC_WAITABLE_TIMER_FWD_DECL)
@@ -142,10 +142,21 @@ class basic_waitable_timer;
template <typename Clock, typename WaitTraits, typename Executor>
class basic_waitable_timer
{
private:
class initiate_async_wait;
public:
/// The type of the executor associated with the object.
typedef Executor executor_type;
/// Rebinds the timer type to another executor.
template <typename Executor1>
struct rebind_executor
{
/// The timer type when rebound to the specified executor.
typedef basic_waitable_timer<Clock, WaitTraits, Executor1> other;
};
/// The clock type.
typedef Clock clock_type;
@@ -168,7 +179,7 @@ public:
* dispatch handlers for any asynchronous operations performed on the timer.
*/
explicit basic_waitable_timer(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@@ -184,10 +195,10 @@ public:
*/
template <typename ExecutionContext>
explicit basic_waitable_timer(ExecutionContext& context,
typename enable_if<
typename constraint<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
>::type = 0)
: impl_(0, 0, context)
{
}
@@ -202,7 +213,7 @@ public:
* as an absolute time.
*/
basic_waitable_timer(const executor_type& ex, const time_point& expiry_time)
: impl_(ex)
: impl_(0, ex)
{
boost::system::error_code ec;
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
@@ -223,10 +234,10 @@ public:
template <typename ExecutionContext>
explicit basic_waitable_timer(ExecutionContext& context,
const time_point& expiry_time,
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().expires_at(impl_.get_implementation(), expiry_time, ec);
@@ -244,7 +255,7 @@ public:
* now.
*/
basic_waitable_timer(const executor_type& ex, const duration& expiry_time)
: impl_(ex)
: impl_(0, ex)
{
boost::system::error_code ec;
impl_.get_service().expires_after(
@@ -266,10 +277,10 @@ public:
template <typename ExecutionContext>
explicit basic_waitable_timer(ExecutionContext& context,
const duration& expiry_time,
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().expires_after(
@@ -311,6 +322,54 @@ public:
impl_ = std::move(other.impl_);
return *this;
}
// All timers have access to each other's implementations.
template <typename Clock1, typename WaitTraits1, typename Executor1>
friend class basic_waitable_timer;
/// Move-construct a basic_waitable_timer from another.
/**
* This constructor moves a timer from one object to another.
*
* @param other The other basic_waitable_timer 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_waitable_timer(const executor_type&)
* constructor.
*/
template <typename Executor1>
basic_waitable_timer(
basic_waitable_timer<Clock, WaitTraits, Executor1>&& other,
typename constraint<
is_convertible<Executor1, Executor>::value
>::type = 0)
: impl_(std::move(other.impl_))
{
}
/// Move-assign a basic_waitable_timer from another.
/**
* This assignment operator moves a timer from one object to another. Cancels
* any outstanding asynchronous operations associated with the target object.
*
* @param other The other basic_waitable_timer 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_waitable_timer(const executor_type&)
* constructor.
*/
template <typename Executor1>
typename constraint<
is_convertible<Executor1, Executor>::value,
basic_waitable_timer&
>::type operator=(basic_waitable_timer<Clock, WaitTraits, Executor1>&& other)
{
basic_waitable_timer tmp(std::move(other));
impl_ = std::move(tmp.impl_);
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroys the timer.
@@ -323,7 +382,7 @@ public:
}
/// 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();
}
@@ -671,34 +730,57 @@ public:
/// Start an asynchronous wait on the timer.
/**
* This function may be used to initiate an asynchronous wait against the
* timer. It always returns immediately.
* timer. It is an initiating function for an @ref asynchronous_operation,
* and always returns immediately.
*
* For each call to async_wait(), the supplied handler will be called exactly
* once. The handler will be called when:
* For each call to async_wait(), the completion handler will be called
* exactly once. The completion handler will be called when:
*
* @li The timer has expired.
*
* @li The timer was cancelled, in which case the handler is passed the error
* code boost::asio::error::operation_aborted.
*
* @param handler The handler to be called when the timer expires. 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 timer expires. 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.
* ); @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 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,
void (boost::system::error_code))
async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
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(
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)))
{
return async_initiate<WaitHandler, void (boost::system::error_code)>(
initiate_async_wait(), handler, this);
return async_initiate<WaitToken, void (boost::system::error_code)>(
initiate_async_wait(this), token);
}
private:
@@ -707,21 +789,36 @@ private:
basic_waitable_timer& operator=(
const basic_waitable_timer&) BOOST_ASIO_DELETED;
struct initiate_async_wait
class initiate_async_wait
{
public:
typedef Executor executor_type;
explicit initiate_async_wait(basic_waitable_timer* 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_waitable_timer* self) const
void operator()(BOOST_ASIO_MOVE_ARG(WaitHandler) handler) 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(), handler2.value,
self->impl_.get_implementation_executor());
self_->impl_.get_service().async_wait(
self_->impl_.get_implementation(),
handler2.value, self_->impl_.get_executor());
}
private:
basic_waitable_timer* self_;
};
detail::io_object_impl<