diff --git a/asio/include/asio/buffered_read_stream.hpp b/asio/include/asio/buffered_read_stream.hpp index f58e4eb3..daa6f596 100644 --- a/asio/include/asio/buffered_read_stream.hpp +++ b/asio/include/asio/buffered_read_stream.hpp @@ -55,6 +55,9 @@ public: /// The type of the lowest layer. typedef typename next_layer_type::lowest_layer_type lowest_layer_type; + /// The type of the executor associated with the object. + typedef typename lowest_layer_type::executor_type executor_type; + #if defined(GENERATING_DOCUMENTATION) /// The default buffer size. static const std::size_t default_buffer_size = implementation_defined; @@ -96,14 +99,21 @@ public: return next_layer_.lowest_layer(); } - /// Get the io_context associated with the object. + /// Get the executor associated with the object. + executor_type get_executor() ASIO_NOEXCEPT + { + return next_layer_.lowest_layer().get_executor(); + } + +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use get_executor().) Get the io_context associated with the + /// object. asio::io_context& get_io_context() { return next_layer_.get_io_context(); } -#if !defined(ASIO_NO_DEPRECATED) - /// (Deprecated: Use get_io_context().) Get the io_context associated with the + /// (Deprecated: Use get_executor().) Get the io_context associated with the /// object. asio::io_context& get_io_service() { diff --git a/asio/include/asio/buffered_stream.hpp b/asio/include/asio/buffered_stream.hpp index 0e840138..516e2134 100644 --- a/asio/include/asio/buffered_stream.hpp +++ b/asio/include/asio/buffered_stream.hpp @@ -52,6 +52,9 @@ public: /// The type of the lowest layer. typedef typename next_layer_type::lowest_layer_type lowest_layer_type; + /// The type of the executor associated with the object. + typedef typename lowest_layer_type::executor_type executor_type; + /// Construct, passing the specified argument to initialise the next layer. template explicit buffered_stream(Arg& a) @@ -87,14 +90,21 @@ public: return stream_impl_.lowest_layer(); } - /// Get the io_context associated with the object. + /// Get the executor associated with the object. + executor_type get_executor() ASIO_NOEXCEPT + { + return stream_impl_.lowest_layer().get_executor(); + } + +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use get_executor().) Get the io_context associated with the + /// object. asio::io_context& get_io_context() { return stream_impl_.get_io_context(); } -#if !defined(ASIO_NO_DEPRECATED) - /// (Deprecated: Use get_io_context().) Get the io_context associated with the + /// (Deprecated: Use get_executor().) Get the io_context associated with the /// object. asio::io_context& get_io_service() { diff --git a/asio/include/asio/buffered_write_stream.hpp b/asio/include/asio/buffered_write_stream.hpp index 0b5ef89e..0fa7547e 100644 --- a/asio/include/asio/buffered_write_stream.hpp +++ b/asio/include/asio/buffered_write_stream.hpp @@ -55,6 +55,9 @@ public: /// The type of the lowest layer. typedef typename next_layer_type::lowest_layer_type lowest_layer_type; + /// The type of the executor associated with the object. + typedef typename lowest_layer_type::executor_type executor_type; + #if defined(GENERATING_DOCUMENTATION) /// The default buffer size. static const std::size_t default_buffer_size = implementation_defined; @@ -96,14 +99,21 @@ public: return next_layer_.lowest_layer(); } - /// Get the io_context associated with the object. + /// Get the executor associated with the object. + executor_type get_executor() ASIO_NOEXCEPT + { + return next_layer_.lowest_layer().get_executor(); + } + +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use get_executor().) Get the io_context associated with the + /// object. asio::io_context& get_io_context() { return next_layer_.get_io_context(); } -#if !defined(ASIO_NO_DEPRECATED) - /// (Deprecated: Use get_io_context().) Get the io_context associated with the + /// (Deprecated: Use get_executor().) Get the io_context associated with the /// object. asio::io_context& get_io_service() { diff --git a/asio/include/asio/ssl/stream.hpp b/asio/include/asio/ssl/stream.hpp index 207bba3d..015066b9 100644 --- a/asio/include/asio/ssl/stream.hpp +++ b/asio/include/asio/ssl/stream.hpp @@ -80,6 +80,9 @@ public: /// The type of the lowest layer. typedef typename next_layer_type::lowest_layer_type lowest_layer_type; + /// The type of the executor associated with the object. + typedef typename lowest_layer_type::executor_type executor_type; + #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct a stream. /** @@ -112,19 +115,34 @@ public: { } - /// Get the io_context associated with the object. + /// Get the executor associated with the object. /** - * This function may be used to obtain the io_context object that the stream + * This function may be used to obtain the executor object that the stream * uses to dispatch handlers for asynchronous operations. * - * @return A reference to the io_context object that stream will use to - * dispatch handlers. Ownership is not transferred to the caller. + * @return A copy of the executor that stream will use to dispatch handlers. */ + executor_type get_executor() ASIO_NOEXCEPT + { + return next_layer_.lowest_layer().get_executor(); + } + +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use get_executor().) Get the io_context associated with the + /// object. asio::io_context& get_io_context() { return next_layer_.lowest_layer().get_io_context(); } + /// (Deprecated: Use get_executor().) Get the io_context associated with the + /// object. + asio::io_context& get_io_service() + { + return next_layer_.lowest_layer().get_io_service(); + } +#endif // !defined(ASIO_NO_DEPRECATED) + /// Get the underlying implementation in the native type. /** * This function may be used to obtain the underlying implementation of the diff --git a/asio/src/examples/cpp03/windows/transmit_file.cpp b/asio/src/examples/cpp03/windows/transmit_file.cpp index 9ea28538..24502a05 100644 --- a/asio/src/examples/cpp03/windows/transmit_file.cpp +++ b/asio/src/examples/cpp03/windows/transmit_file.cpp @@ -28,7 +28,7 @@ void transmit_file(tcp::socket& socket, random_access_handle& file, Handler handler) { // Construct an OVERLAPPED-derived object to contain the handler. - overlapped_ptr overlapped(socket.get_io_context(), handler); + overlapped_ptr overlapped(socket.get_executor().context(), handler); // Initiate the TransmitFile operation. BOOL ok = ::TransmitFile(socket.native_handle(), @@ -119,7 +119,7 @@ private: void start_accept() { connection::pointer new_connection = - connection::create(acceptor_.get_io_context(), filename_); + connection::create(acceptor_.get_executor().context(), filename_); acceptor_.async_accept(new_connection->socket(), boost::bind(&server::handle_accept, this, new_connection, diff --git a/asio/src/tests/unit/buffered_read_stream.cpp b/asio/src/tests/unit/buffered_read_stream.cpp index 06047c2e..b4cb4fd4 100644 --- a/asio/src/tests/unit/buffered_read_stream.cpp +++ b/asio/src/tests/unit/buffered_read_stream.cpp @@ -78,9 +78,17 @@ void test_compile() stream_type stream1(ioc); stream_type stream2(ioc, 1024); + stream_type::executor_type ex = stream1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = stream1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = stream1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer(); (void)lowest_layer; diff --git a/asio/src/tests/unit/buffered_stream.cpp b/asio/src/tests/unit/buffered_stream.cpp index a55a2a59..3d5f4794 100644 --- a/asio/src/tests/unit/buffered_stream.cpp +++ b/asio/src/tests/unit/buffered_stream.cpp @@ -82,9 +82,17 @@ void test_compile() stream_type stream1(ioc); stream_type stream2(ioc, 1024, 1024); + stream_type::executor_type ex = stream1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = stream1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = stream1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer(); (void)lowest_layer; diff --git a/asio/src/tests/unit/buffered_write_stream.cpp b/asio/src/tests/unit/buffered_write_stream.cpp index cf3a8199..a9731e0f 100644 --- a/asio/src/tests/unit/buffered_write_stream.cpp +++ b/asio/src/tests/unit/buffered_write_stream.cpp @@ -78,9 +78,17 @@ void test_compile() stream_type stream1(ioc); stream_type stream2(ioc, 1024); + stream_type::executor_type ex = stream1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = stream1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = stream1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer(); (void)lowest_layer; diff --git a/asio/src/tests/unit/generic/datagram_protocol.cpp b/asio/src/tests/unit/generic/datagram_protocol.cpp index 58da16a8..bb2c39bc 100644 --- a/asio/src/tests/unit/generic/datagram_protocol.cpp +++ b/asio/src/tests/unit/generic/datagram_protocol.cpp @@ -94,9 +94,17 @@ void test() // basic_io_object functions. + dp::socket::executor_type ex = socket1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = socket1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = socket1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + // basic_socket functions. dp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); diff --git a/asio/src/tests/unit/generic/raw_protocol.cpp b/asio/src/tests/unit/generic/raw_protocol.cpp index 0ba8c119..b3d72f08 100644 --- a/asio/src/tests/unit/generic/raw_protocol.cpp +++ b/asio/src/tests/unit/generic/raw_protocol.cpp @@ -94,9 +94,17 @@ void test() // basic_io_object functions. + rp::socket::executor_type ex = socket1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = socket1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = socket1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + // basic_socket functions. rp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); diff --git a/asio/src/tests/unit/generic/seq_packet_protocol.cpp b/asio/src/tests/unit/generic/seq_packet_protocol.cpp index a2ba7be7..da191653 100644 --- a/asio/src/tests/unit/generic/seq_packet_protocol.cpp +++ b/asio/src/tests/unit/generic/seq_packet_protocol.cpp @@ -90,9 +90,17 @@ void test() // basic_io_object functions. + spp::socket::executor_type ex = socket1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = socket1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = socket1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + // basic_socket functions. spp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); diff --git a/asio/src/tests/unit/generic/stream_protocol.cpp b/asio/src/tests/unit/generic/stream_protocol.cpp index 4a93f26f..16711c56 100644 --- a/asio/src/tests/unit/generic/stream_protocol.cpp +++ b/asio/src/tests/unit/generic/stream_protocol.cpp @@ -104,9 +104,17 @@ void test() // basic_io_object functions. + sp::socket::executor_type ex = socket1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = socket1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = socket1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + // basic_socket functions. sp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); diff --git a/asio/src/tests/unit/is_read_buffered.cpp b/asio/src/tests/unit/is_read_buffered.cpp index ee234781..f4ca5c9b 100644 --- a/asio/src/tests/unit/is_read_buffered.cpp +++ b/asio/src/tests/unit/is_read_buffered.cpp @@ -31,6 +31,8 @@ public: typedef test_stream lowest_layer_type; + typedef io_context_type::executor_type executor_type; + test_stream(asio::io_context& io_context) : io_context_(io_context) { diff --git a/asio/src/tests/unit/is_write_buffered.cpp b/asio/src/tests/unit/is_write_buffered.cpp index 3b26c275..206a8a5f 100644 --- a/asio/src/tests/unit/is_write_buffered.cpp +++ b/asio/src/tests/unit/is_write_buffered.cpp @@ -31,6 +31,8 @@ public: typedef test_stream lowest_layer_type; + typedef io_context_type::executor_type executor_type; + test_stream(asio::io_context& io_context) : io_context_(io_context) { diff --git a/asio/src/tests/unit/serial_port.cpp b/asio/src/tests/unit/serial_port.cpp index 6171afc9..0a7f0411 100644 --- a/asio/src/tests/unit/serial_port.cpp +++ b/asio/src/tests/unit/serial_port.cpp @@ -86,9 +86,17 @@ void test() // basic_io_object functions. + serial_port::executor_type ex = port1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = port1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = port1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + // basic_serial_port functions. serial_port::lowest_layer_type& lowest_layer = port1.lowest_layer(); diff --git a/asio/src/tests/unit/signal_set.cpp b/asio/src/tests/unit/signal_set.cpp index c0356d29..88b983af 100644 --- a/asio/src/tests/unit/signal_set.cpp +++ b/asio/src/tests/unit/signal_set.cpp @@ -52,9 +52,17 @@ void test() // basic_io_object functions. + signal_set::executor_type ex = set1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = set1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = set1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + // basic_signal_set functions. set1.add(1); diff --git a/asio/src/tests/unit/ssl/stream.cpp b/asio/src/tests/unit/ssl/stream.cpp index 2020283c..bac2c232 100644 --- a/asio/src/tests/unit/ssl/stream.cpp +++ b/asio/src/tests/unit/ssl/stream.cpp @@ -77,9 +77,17 @@ void test() // basic_io_object functions. + ssl::stream::executor_type ex = stream1.get_executor(); + (void)ex; + +#if !defined(ASIO_NO_DEPRECATED) io_context& ioc_ref = stream1.get_io_context(); (void)ioc_ref; + io_context& ioc_ref2 = stream1.get_io_service(); + (void)ioc_ref2; +#endif // !defined(ASIO_NO_DEPRECATED) + // ssl::stream functions. SSL* ssl1 = stream1.native_handle();