update boost
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// io_object_impl.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,42 +17,18 @@
|
||||
|
||||
#include <new>
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/detail/io_object_executor.hpp>
|
||||
#include <boost/asio/detail/type_traits.hpp>
|
||||
#include <boost/asio/execution/executor.hpp>
|
||||
#include <boost/asio/execution/context.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/query.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
class executor;
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline bool is_native_io_executor(const io_context::executor_type&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Executor>
|
||||
inline bool is_native_io_executor(const Executor&,
|
||||
typename enable_if<!is_same<Executor, executor>::value>::type* = 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Executor>
|
||||
inline bool is_native_io_executor(const Executor& ex,
|
||||
typename enable_if<is_same<Executor, executor>::value>::type* = 0)
|
||||
{
|
||||
#if !defined (BOOST_ASIO_NO_TYPEID)
|
||||
return ex.target_type() == typeid(io_context::executor_type);
|
||||
#else // !defined (BOOST_ASIO_NO_TYPEID)
|
||||
return false;
|
||||
#endif // !defined (BOOST_ASIO_NO_TYPEID)
|
||||
}
|
||||
|
||||
template <typename IoObjectService,
|
||||
typename Executor = io_context::executor_type>
|
||||
class io_object_impl
|
||||
@@ -67,25 +43,20 @@ public:
|
||||
// The type of the executor associated with the object.
|
||||
typedef Executor executor_type;
|
||||
|
||||
// The type of executor to be used when implementing asynchronous operations.
|
||||
typedef io_object_executor<Executor> implementation_executor_type;
|
||||
|
||||
// Construct an I/O object using an executor.
|
||||
explicit io_object_impl(const executor_type& ex)
|
||||
: service_(&boost::asio::use_service<IoObjectService>(ex.context())),
|
||||
implementation_executor_(ex, (is_native_io_executor)(ex))
|
||||
explicit io_object_impl(int, const executor_type& ex)
|
||||
: service_(&boost::asio::use_service<IoObjectService>(
|
||||
io_object_impl::get_context(ex))),
|
||||
executor_(ex)
|
||||
{
|
||||
service_->construct(implementation_);
|
||||
}
|
||||
|
||||
// Construct an I/O object using an execution context.
|
||||
template <typename ExecutionContext>
|
||||
explicit io_object_impl(ExecutionContext& context,
|
||||
typename enable_if<is_convertible<
|
||||
ExecutionContext&, execution_context&>::value>::type* = 0)
|
||||
explicit io_object_impl(int, int, ExecutionContext& context)
|
||||
: service_(&boost::asio::use_service<IoObjectService>(context)),
|
||||
implementation_executor_(context.get_executor(),
|
||||
is_same<ExecutionContext, io_context>::value)
|
||||
executor_(context.get_executor())
|
||||
{
|
||||
service_->construct(implementation_);
|
||||
}
|
||||
@@ -94,17 +65,26 @@ public:
|
||||
// Move-construct an I/O object.
|
||||
io_object_impl(io_object_impl&& other)
|
||||
: service_(&other.get_service()),
|
||||
implementation_executor_(other.get_implementation_executor())
|
||||
executor_(other.get_executor())
|
||||
{
|
||||
service_->move_construct(implementation_, other.implementation_);
|
||||
}
|
||||
|
||||
// Perform a converting move-construction of an I/O object.
|
||||
// Perform converting move-construction of an I/O object on the same service.
|
||||
template <typename Executor1>
|
||||
io_object_impl(io_object_impl<IoObjectService, Executor1>&& other)
|
||||
: service_(&other.get_service()),
|
||||
executor_(other.get_executor())
|
||||
{
|
||||
service_->move_construct(implementation_, other.get_implementation());
|
||||
}
|
||||
|
||||
// Perform converting move-construction of an I/O object on another service.
|
||||
template <typename IoObjectService1, typename Executor1>
|
||||
io_object_impl(io_object_impl<IoObjectService1, Executor1>&& other)
|
||||
: service_(&boost::asio::use_service<IoObjectService>(
|
||||
other.get_implementation_executor().context())),
|
||||
implementation_executor_(other.get_implementation_executor())
|
||||
io_object_impl::get_context(other.get_executor()))),
|
||||
executor_(other.get_executor())
|
||||
{
|
||||
service_->converting_move_construct(implementation_,
|
||||
other.get_service(), other.get_implementation());
|
||||
@@ -125,9 +105,8 @@ public:
|
||||
{
|
||||
service_->move_assign(implementation_,
|
||||
*other.service_, other.implementation_);
|
||||
implementation_executor_.~implementation_executor_type();
|
||||
new (&implementation_executor_) implementation_executor_type(
|
||||
std::move(other.implementation_executor_));
|
||||
executor_.~executor_type();
|
||||
new (&executor_) executor_type(other.executor_);
|
||||
service_ = other.service_;
|
||||
}
|
||||
return *this;
|
||||
@@ -135,16 +114,9 @@ public:
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
// Get the executor associated with the object.
|
||||
executor_type get_executor() BOOST_ASIO_NOEXCEPT
|
||||
const executor_type& get_executor() BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return implementation_executor_.inner_executor();
|
||||
}
|
||||
|
||||
// Get the executor to be used when implementing asynchronous operations.
|
||||
const implementation_executor_type& get_implementation_executor()
|
||||
BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return implementation_executor_;
|
||||
return executor_;
|
||||
}
|
||||
|
||||
// Get the service associated with the I/O object.
|
||||
@@ -172,6 +144,22 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
// Helper function to get an executor's context.
|
||||
template <typename T>
|
||||
static execution_context& get_context(const T& t,
|
||||
typename enable_if<execution::is_executor<T>::value>::type* = 0)
|
||||
{
|
||||
return boost::asio::query(t, execution::context);
|
||||
}
|
||||
|
||||
// Helper function to get an executor's context.
|
||||
template <typename T>
|
||||
static execution_context& get_context(const T& t,
|
||||
typename enable_if<!execution::is_executor<T>::value>::type* = 0)
|
||||
{
|
||||
return t.context();
|
||||
}
|
||||
|
||||
// Disallow copying and copy assignment.
|
||||
io_object_impl(const io_object_impl&);
|
||||
io_object_impl& operator=(const io_object_impl&);
|
||||
@@ -183,7 +171,7 @@ private:
|
||||
implementation_type implementation_;
|
||||
|
||||
// The associated executor.
|
||||
implementation_executor_type implementation_executor_;
|
||||
executor_type executor_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
Reference in New Issue
Block a user