Fix up some I/O objects to use non-deprecated get_executor().

This commit is contained in:
Christopher Kohlhoff 2015-05-13 09:52:41 +10:00
parent f1ebd9522f
commit 24c6d7e3c7
17 changed files with 147 additions and 15 deletions

View File

@ -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()
{

View File

@ -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 <typename Arg>
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()
{

View File

@ -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()
{

View File

@ -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

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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();

View File

@ -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);

View File

@ -77,9 +77,17 @@ void test()
// basic_io_object functions.
ssl::stream<ip::tcp::socket>::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();