Merge commit 'f44694ce5f781924b6094c4c18f8bf83a3da7857' into feature/update-dependencies

This commit is contained in:
Sergey Abramchuk
2019-10-25 20:20:11 +03:00
9 changed files with 83 additions and 25 deletions
@@ -1,4 +1,4 @@
asio version 1.13.0 asio version 1.14.0
Released Tuesday, 12 March 2019. Released Sunday, 14 April 2019.
See doc/index.html for API documentation and a tutorial. See doc/index.html for API documentation and a tutorial.
@@ -1,4 +1,4 @@
AC_INIT(asio, [1.13.0]) AC_INIT(asio, [1.14.0])
AC_CONFIG_SRCDIR(include/asio.hpp) AC_CONFIG_SRCDIR(include/asio.hpp)
AM_MAINTAINER_MODE AM_MAINTAINER_MODE
AM_INIT_AUTOMAKE([tar-ustar]) AM_INIT_AUTOMAKE([tar-ustar])
@@ -24,8 +24,34 @@
#include "asio/detail/push_options.hpp" #include "asio/detail/push_options.hpp"
namespace asio { namespace asio {
class executor;
namespace detail { 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 (ASIO_NO_TYPEID)
return ex.target_type() == typeid(io_context::executor_type);
#else // !defined (ASIO_NO_TYPEID)
return false;
#endif // !defined (ASIO_NO_TYPEID)
}
template <typename IoObjectService, template <typename IoObjectService,
typename Executor = io_context::executor_type> typename Executor = io_context::executor_type>
class io_object_impl class io_object_impl
@@ -46,8 +72,7 @@ public:
// Construct an I/O object using an executor. // Construct an I/O object using an executor.
explicit io_object_impl(const executor_type& ex) explicit io_object_impl(const executor_type& ex)
: service_(&asio::use_service<IoObjectService>(ex.context())), : service_(&asio::use_service<IoObjectService>(ex.context())),
implementation_executor_(ex, implementation_executor_(ex, (is_native_io_executor)(ex))
is_same<Executor, io_context::executor_type>::value)
{ {
service_->construct(implementation_); service_->construct(implementation_);
} }
@@ -68,9 +93,7 @@ public:
// Move-construct an I/O object. // Move-construct an I/O object.
io_object_impl(io_object_impl&& other) io_object_impl(io_object_impl&& other)
: service_(&other.get_service()), : service_(&other.get_service()),
implementation_executor_( implementation_executor_(other.get_implementation_executor())
ASIO_MOVE_CAST(implementation_executor_type)(
other.implementation_executor_))
{ {
service_->move_construct(implementation_, other.implementation_); service_->move_construct(implementation_, other.implementation_);
} }
@@ -151,8 +151,10 @@ private:
template <typename Protocol, typename PeerIoExecutor, template <typename Protocol, typename PeerIoExecutor,
typename Handler, typename IoExecutor> typename Handler, typename IoExecutor>
class reactive_socket_move_accept_op : class reactive_socket_move_accept_op :
private Protocol::socket, private Protocol::socket::template rebind_executor<PeerIoExecutor>::other,
public reactive_socket_accept_op_base<typename Protocol::socket, Protocol> public reactive_socket_accept_op_base<
typename Protocol::socket::template rebind_executor<PeerIoExecutor>::other,
Protocol>
{ {
public: public:
ASIO_DEFINE_HANDLER_PTR(reactive_socket_move_accept_op); ASIO_DEFINE_HANDLER_PTR(reactive_socket_move_accept_op);
@@ -161,8 +163,8 @@ public:
socket_type socket, socket_ops::state_type state, socket_type socket, socket_ops::state_type state,
const Protocol& protocol, typename Protocol::endpoint* peer_endpoint, const Protocol& protocol, typename Protocol::endpoint* peer_endpoint,
Handler& handler, const IoExecutor& io_ex) Handler& handler, const IoExecutor& io_ex)
: Protocol::socket(peer_io_ex), : peer_socket_type(peer_io_ex),
reactive_socket_accept_op_base<typename Protocol::socket, Protocol>( reactive_socket_accept_op_base<peer_socket_type, Protocol>(
socket, state, *this, protocol, peer_endpoint, socket, state, *this, protocol, peer_endpoint,
&reactive_socket_move_accept_op::do_complete), &reactive_socket_move_accept_op::do_complete),
handler_(ASIO_MOVE_CAST(Handler)(handler)), handler_(ASIO_MOVE_CAST(Handler)(handler)),
@@ -194,9 +196,9 @@ public:
// to ensure that any owning sub-object remains valid until after we have // to ensure that any owning sub-object remains valid until after we have
// deallocated the memory here. // deallocated the memory here.
detail::move_binder2<Handler, detail::move_binder2<Handler,
asio::error_code, typename Protocol::socket> asio::error_code, peer_socket_type>
handler(0, ASIO_MOVE_CAST(Handler)(o->handler_), o->ec_, handler(0, ASIO_MOVE_CAST(Handler)(o->handler_), o->ec_,
ASIO_MOVE_CAST(typename Protocol::socket)(*o)); ASIO_MOVE_CAST(peer_socket_type)(*o));
p.h = asio::detail::addressof(handler.handler_); p.h = asio::detail::addressof(handler.handler_);
p.reset(); p.reset();
@@ -211,6 +213,9 @@ public:
} }
private: private:
typedef typename Protocol::socket::template
rebind_executor<PeerIoExecutor>::other peer_socket_type;
Handler handler_; Handler handler_;
IoExecutor io_executor_; IoExecutor io_executor_;
}; };
@@ -35,7 +35,7 @@ struct win_global_impl
static win_global_impl instance_; static win_global_impl instance_;
static static_mutex mutex_; static static_mutex mutex_;
static T* ptr_; T* ptr_;
static tss_ptr<T> tss_ptr_; static tss_ptr<T> tss_ptr_;
}; };
@@ -45,9 +45,6 @@ win_global_impl<T> win_global_impl<T>::instance_ = { 0 };
template <typename T> template <typename T>
static_mutex win_global_impl<T>::mutex_ = ASIO_STATIC_MUTEX_INIT; static_mutex win_global_impl<T>::mutex_ = ASIO_STATIC_MUTEX_INIT;
template <typename T>
T* win_global_impl<T>::ptr_ = 0;
template <typename T> template <typename T>
tss_ptr<T> win_global_impl<T>::tss_ptr_; tss_ptr<T> win_global_impl<T>::tss_ptr_;
@@ -58,9 +55,9 @@ T& win_global()
{ {
win_global_impl<T>::mutex_.init(); win_global_impl<T>::mutex_.init();
static_mutex::scoped_lock lock(win_global_impl<T>::mutex_); static_mutex::scoped_lock lock(win_global_impl<T>::mutex_);
if (win_global_impl<T>::ptr_ == 0) if (win_global_impl<T>::instance_.ptr_ == 0)
win_global_impl<T>::ptr_ = new T; win_global_impl<T>::instance_.ptr_ = new T;
win_global_impl<T>::tss_ptr_ = win_global_impl<T>::ptr_; win_global_impl<T>::tss_ptr_ = win_global_impl<T>::instance_.ptr_;
} }
return *win_global_impl<T>::tss_ptr_; return *win_global_impl<T>::tss_ptr_;
@@ -262,9 +262,9 @@ public:
// to ensure that any owning sub-object remains valid until after we have // to ensure that any owning sub-object remains valid until after we have
// deallocated the memory here. // deallocated the memory here.
detail::move_binder2<Handler, detail::move_binder2<Handler,
asio::error_code, typename Protocol::socket> asio::error_code, peer_socket_type>
handler(0, ASIO_MOVE_CAST(Handler)(o->handler_), ec, handler(0, ASIO_MOVE_CAST(Handler)(o->handler_), ec,
ASIO_MOVE_CAST(typename Protocol::socket)(o->peer_)); ASIO_MOVE_CAST(peer_socket_type)(o->peer_));
p.h = asio::detail::addressof(handler.handler_); p.h = asio::detail::addressof(handler.handler_);
p.reset(); p.reset();
@@ -279,10 +279,13 @@ public:
} }
private: private:
typedef typename Protocol::socket::template
rebind_executor<PeerIoExecutor>::other peer_socket_type;
win_iocp_socket_service_base& socket_service_; win_iocp_socket_service_base& socket_service_;
socket_type socket_; socket_type socket_;
socket_holder new_socket_; socket_holder new_socket_;
typename Protocol::socket peer_; peer_socket_type peer_;
Protocol protocol_; Protocol protocol_;
typename Protocol::endpoint* peer_endpoint_; typename Protocol::endpoint* peer_endpoint_;
unsigned char output_buffer_[(sizeof(sockaddr_storage_type) + 16) * 2]; unsigned char output_buffer_[(sizeof(sockaddr_storage_type) + 16) * 2];
@@ -18,6 +18,6 @@
// ASIO_VERSION % 100 is the sub-minor version // ASIO_VERSION % 100 is the sub-minor version
// ASIO_VERSION / 100 % 1000 is the minor version // ASIO_VERSION / 100 % 1000 is the minor version
// ASIO_VERSION / 100000 is the major version // ASIO_VERSION / 100000 is the major version
#define ASIO_VERSION 101300 // 1.13.0 #define ASIO_VERSION 101400 // 1.14.0
#endif // ASIO_VERSION_HPP #endif // ASIO_VERSION_HPP
@@ -7,6 +7,21 @@
[section:history Revision History] [section:history Revision History]
[heading Asio 1.14.0]
* Improved I/O object performance by adding runtime detection of native I/O
executors when using the polymorphic executor wrapper.
* Changed I/O object move constructors so that the executor is copied, not
moved. This ensures that the moved-from I/O object is left in the same state
as if constructed with a valid executor but without a resource.
* On Windows, fixed an issue where global object destructors were not being
run.
* Fixed move-based `async_accept` between sockets with different executor
types.
[heading Asio 1.13.0] [heading Asio 1.13.0]
* Added custom I/O executor support to I/O objects. * Added custom I/O executor support to I/O objects.
@@ -729,6 +729,17 @@ struct move_accept_handler
private: private:
move_accept_handler(const move_accept_handler&) {} move_accept_handler(const move_accept_handler&) {}
}; };
struct move_accept_ioc_handler
{
move_accept_ioc_handler() {}
void operator()(const asio::error_code&,
asio::basic_stream_socket<asio::ip::tcp,
asio::io_context::executor_type>) {}
move_accept_ioc_handler(move_accept_handler&&) {}
private:
move_accept_ioc_handler(const move_accept_handler&) {}
};
#endif // defined(ASIO_HAS_MOVE) #endif // defined(ASIO_HAS_MOVE)
void test() void test()
@@ -913,8 +924,12 @@ void test()
#if defined(ASIO_HAS_MOVE) #if defined(ASIO_HAS_MOVE)
acceptor1.async_accept(move_accept_handler()); acceptor1.async_accept(move_accept_handler());
acceptor1.async_accept(ioc, move_accept_handler()); acceptor1.async_accept(ioc, move_accept_handler());
acceptor1.async_accept(ioc_ex, move_accept_handler());
acceptor1.async_accept(ioc_ex, move_accept_ioc_handler());
acceptor1.async_accept(peer_endpoint, move_accept_handler()); acceptor1.async_accept(peer_endpoint, move_accept_handler());
acceptor1.async_accept(ioc, peer_endpoint, move_accept_handler()); acceptor1.async_accept(ioc, peer_endpoint, move_accept_handler());
acceptor1.async_accept(ioc_ex, peer_endpoint, move_accept_handler());
acceptor1.async_accept(ioc_ex, peer_endpoint, move_accept_ioc_handler());
#endif // defined(ASIO_HAS_MOVE) #endif // defined(ASIO_HAS_MOVE)
} }
catch (std::exception&) catch (std::exception&)