diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
commit | 3c1df2168531ad5580076ae08d529054689aeedd (patch) | |
tree | 941aff6f86393eecacddfec252a8508c7e8351c9 /boost/asio/detail/reactive_socket_accept_op.hpp | |
parent | d6a306e745acfee00e81ccaf3324a2a03516db41 (diff) | |
download | boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.gz boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.bz2 boost-3c1df2168531ad5580076ae08d529054689aeedd.zip |
Imported Upstream version 1.70.0upstream/1.70.0
Diffstat (limited to 'boost/asio/detail/reactive_socket_accept_op.hpp')
-rw-r--r-- | boost/asio/detail/reactive_socket_accept_op.hpp | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/boost/asio/detail/reactive_socket_accept_op.hpp b/boost/asio/detail/reactive_socket_accept_op.hpp index 292f3bdf25..972e01618c 100644 --- a/boost/asio/detail/reactive_socket_accept_op.hpp +++ b/boost/asio/detail/reactive_socket_accept_op.hpp @@ -2,7 +2,7 @@ // detail/reactive_socket_accept_op.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2019 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) @@ -86,7 +86,8 @@ private: std::size_t addrlen_; }; -template <typename Socket, typename Protocol, typename Handler> +template <typename Socket, typename Protocol, + typename Handler, typename IoExecutor> class reactive_socket_accept_op : public reactive_socket_accept_op_base<Socket, Protocol> { @@ -95,12 +96,14 @@ public: reactive_socket_accept_op(socket_type socket, socket_ops::state_type state, Socket& peer, const Protocol& protocol, - typename Protocol::endpoint* peer_endpoint, Handler& handler) + typename Protocol::endpoint* peer_endpoint, Handler& handler, + const IoExecutor& io_ex) : reactive_socket_accept_op_base<Socket, Protocol>(socket, state, peer, protocol, peer_endpoint, &reactive_socket_accept_op::do_complete), - handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)) + handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)), + io_executor_(io_ex) { - handler_work<Handler>::start(handler_); + handler_work<Handler, IoExecutor>::start(handler_, io_executor_); } static void do_complete(void* owner, operation* base, @@ -110,7 +113,7 @@ public: // Take ownership of the handler object. reactive_socket_accept_op* o(static_cast<reactive_socket_accept_op*>(base)); ptr p = { boost::asio::detail::addressof(o->handler_), o, o }; - handler_work<Handler> w(o->handler_); + handler_work<Handler, IoExecutor> w(o->handler_, o->io_executor_); // On success, assign new connection to peer socket object. if (owner) @@ -141,28 +144,34 @@ public: private: Handler handler_; + IoExecutor io_executor_; }; #if defined(BOOST_ASIO_HAS_MOVE) -template <typename Protocol, typename Handler> +template <typename Protocol, typename PeerIoExecutor, + typename Handler, typename IoExecutor> class reactive_socket_move_accept_op : - private Protocol::socket, - public reactive_socket_accept_op_base<typename Protocol::socket, Protocol> + private Protocol::socket::template rebind_executor<PeerIoExecutor>::other, + public reactive_socket_accept_op_base< + typename Protocol::socket::template rebind_executor<PeerIoExecutor>::other, + Protocol> { public: BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_move_accept_op); - reactive_socket_move_accept_op(io_context& ioc, socket_type socket, - socket_ops::state_type state, const Protocol& protocol, - typename Protocol::endpoint* peer_endpoint, Handler& handler) - : Protocol::socket(ioc), - reactive_socket_accept_op_base<typename Protocol::socket, Protocol>( + reactive_socket_move_accept_op(const PeerIoExecutor& peer_io_ex, + socket_type socket, socket_ops::state_type state, + const Protocol& protocol, typename Protocol::endpoint* peer_endpoint, + Handler& handler, const IoExecutor& io_ex) + : peer_socket_type(peer_io_ex), + reactive_socket_accept_op_base<peer_socket_type, Protocol>( socket, state, *this, protocol, peer_endpoint, &reactive_socket_move_accept_op::do_complete), - handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)) + handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)), + io_executor_(io_ex) { - handler_work<Handler>::start(handler_); + handler_work<Handler, IoExecutor>::start(handler_, io_executor_); } static void do_complete(void* owner, operation* base, @@ -173,7 +182,7 @@ public: reactive_socket_move_accept_op* o( static_cast<reactive_socket_move_accept_op*>(base)); ptr p = { boost::asio::detail::addressof(o->handler_), o, o }; - handler_work<Handler> w(o->handler_); + handler_work<Handler, IoExecutor> w(o->handler_, o->io_executor_); // On success, assign new connection to peer socket object. if (owner) @@ -188,9 +197,9 @@ public: // to ensure that any owning sub-object remains valid until after we have // deallocated the memory here. detail::move_binder2<Handler, - boost::system::error_code, typename Protocol::socket> + boost::system::error_code, peer_socket_type> handler(0, BOOST_ASIO_MOVE_CAST(Handler)(o->handler_), o->ec_, - BOOST_ASIO_MOVE_CAST(typename Protocol::socket)(*o)); + BOOST_ASIO_MOVE_CAST(peer_socket_type)(*o)); p.h = boost::asio::detail::addressof(handler.handler_); p.reset(); @@ -205,7 +214,11 @@ public: } private: + typedef typename Protocol::socket::template + rebind_executor<PeerIoExecutor>::other peer_socket_type; + Handler handler_; + IoExecutor io_executor_; }; #endif // defined(BOOST_ASIO_HAS_MOVE) |