Add move support for resolver objects.
This commit is contained in:
parent
a1f71f95c4
commit
9fb2d82fbe
@ -98,6 +98,19 @@ void resolver_service_base::destroy(
|
||||
impl.reset();
|
||||
}
|
||||
|
||||
void resolver_service_base::move_construct(implementation_type& impl,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
impl = ASIO_MOVE_CAST(implementation_type)(other_impl);
|
||||
}
|
||||
|
||||
void resolver_service_base::move_assign(implementation_type& impl,
|
||||
resolver_service_base&, implementation_type& other_impl)
|
||||
{
|
||||
destroy(impl);
|
||||
impl = ASIO_MOVE_CAST(implementation_type)(other_impl);
|
||||
}
|
||||
|
||||
void resolver_service_base::cancel(
|
||||
resolver_service_base::implementation_type& impl)
|
||||
{
|
||||
|
@ -57,6 +57,15 @@ public:
|
||||
// Destroy a resolver implementation.
|
||||
ASIO_DECL void destroy(implementation_type&);
|
||||
|
||||
// Move-construct a new resolver implementation.
|
||||
ASIO_DECL void move_construct(implementation_type& impl,
|
||||
implementation_type& other_impl);
|
||||
|
||||
// Move-assign from another resolver implementation.
|
||||
ASIO_DECL void move_assign(implementation_type& impl,
|
||||
resolver_service_base& other_service,
|
||||
implementation_type& other_impl);
|
||||
|
||||
// Cancel pending asynchronous operations.
|
||||
ASIO_DECL void cancel(implementation_type& impl);
|
||||
|
||||
|
@ -80,6 +80,18 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// Move-construct a new resolver implementation.
|
||||
void move_construct(implementation_type&,
|
||||
implementation_type&)
|
||||
{
|
||||
}
|
||||
|
||||
// Move-assign from another resolver implementation.
|
||||
void move_assign(implementation_type&,
|
||||
winrt_resolver_service&, implementation_type&)
|
||||
{
|
||||
}
|
||||
|
||||
// Destroy a resolver implementation.
|
||||
void destroy(implementation_type&)
|
||||
{
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include "asio/ip/basic_resolver_results.hpp"
|
||||
#include "asio/ip/resolver_base.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
# include <utility>
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
#if defined(ASIO_ENABLE_OLD_SERVICES)
|
||||
# include "asio/ip/resolver_service.hpp"
|
||||
#else // defined(ASIO_ENABLE_OLD_SERVICES)
|
||||
@ -88,13 +92,49 @@ public:
|
||||
* This constructor creates a basic_resolver.
|
||||
*
|
||||
* @param io_context The io_context object that the resolver will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the timer.
|
||||
* dispatch handlers for any asynchronous operations performed on the
|
||||
* resolver.
|
||||
*/
|
||||
explicit basic_resolver(asio::io_context& io_context)
|
||||
: basic_io_object<ASIO_SVC_T>(io_context)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_resolver from another.
|
||||
/**
|
||||
* This constructor moves a resolver from one object to another.
|
||||
*
|
||||
* @param other The other basic_resolver 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_resolver(io_context&) constructor.
|
||||
*/
|
||||
basic_resolver(basic_resolver&& other)
|
||||
: basic_io_object<ASIO_SVC_T>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_resolver from another.
|
||||
/**
|
||||
* This assignment operator moves a resolver from one object to another.
|
||||
* Cancels any outstanding asynchronous operations associated with the target
|
||||
* object.
|
||||
*
|
||||
* @param other The other basic_resolver 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_resolver(io_context&) constructor.
|
||||
*/
|
||||
basic_resolver& operator=(basic_resolver&& other)
|
||||
{
|
||||
basic_io_object<ASIO_SVC_T>::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Destroys the resolver.
|
||||
/**
|
||||
* This function destroys the resolver, cancelling any outstanding
|
||||
|
@ -100,6 +100,23 @@ public:
|
||||
service_impl_.construct(impl);
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a new resolver implementation.
|
||||
void move_construct(implementation_type& impl,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_construct(impl, other_impl);
|
||||
}
|
||||
|
||||
/// Move-assign from another resolver implementation.
|
||||
void move_assign(implementation_type& impl,
|
||||
resolver_service& other_service,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Destroy a resolver implementation.
|
||||
void destroy(implementation_type& impl)
|
||||
{
|
||||
|
@ -444,6 +444,17 @@ void test()
|
||||
|
||||
ip::icmp::resolver resolver(ioc);
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
ip::icmp::resolver resolver2(std::move(resolver));
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
// basic_resolver operators.
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
resolver = ip::icmp::resolver(ioc);
|
||||
resolver = std::move(resolver2);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
// basic_io_object functions.
|
||||
|
||||
io_context& ioc_ref = resolver.get_io_context();
|
||||
|
@ -985,6 +985,17 @@ void test()
|
||||
|
||||
ip::tcp::resolver resolver(ioc);
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
ip::tcp::resolver resolver2(std::move(resolver));
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
// basic_resolver operators.
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
resolver = ip::tcp::resolver(ioc);
|
||||
resolver = std::move(resolver2);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
// basic_io_object functions.
|
||||
|
||||
io_context& ioc_ref = resolver.get_io_context();
|
||||
|
@ -541,6 +541,17 @@ void test()
|
||||
|
||||
ip::udp::resolver resolver(ioc);
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
ip::udp::resolver resolver2(std::move(resolver));
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
// basic_resolver operators.
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
resolver = ip::udp::resolver(ioc);
|
||||
resolver = std::move(resolver2);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
// basic_io_object functions.
|
||||
|
||||
io_context& ioc_ref = resolver.get_io_context();
|
||||
|
Loading…
Reference in New Issue
Block a user