Rename io_service to io_context.

This commit is contained in:
Christopher Kohlhoff 2015-05-10 22:22:34 +10:00
parent b056bff78d
commit 45124f33b8
293 changed files with 6038 additions and 5898 deletions

View File

@ -112,8 +112,8 @@ nobase_include_HEADERS = \
asio/detail/impl/timer_queue_set.ipp \
asio/detail/impl/win_event.ipp \
asio/detail/impl/win_iocp_handle_service.ipp \
asio/detail/impl/win_iocp_io_service.hpp \
asio/detail/impl/win_iocp_io_service.ipp \
asio/detail/impl/win_iocp_io_context.hpp \
asio/detail/impl/win_iocp_io_context.ipp \
asio/detail/impl/win_iocp_serial_port_service.ipp \
asio/detail/impl/win_iocp_socket_service_base.ipp \
asio/detail/impl/win_mutex.ipp \
@ -235,7 +235,7 @@ nobase_include_HEADERS = \
asio/detail/win_iocp_handle_read_op.hpp \
asio/detail/win_iocp_handle_service.hpp \
asio/detail/win_iocp_handle_write_op.hpp \
asio/detail/win_iocp_io_service.hpp \
asio/detail/win_iocp_io_context.hpp \
asio/detail/win_iocp_null_buffers_op.hpp \
asio/detail/win_iocp_operation.hpp \
asio/detail/win_iocp_overlapped_op.hpp \
@ -301,8 +301,8 @@ nobase_include_HEADERS = \
asio/impl/executor.hpp \
asio/impl/executor.ipp \
asio/impl/handler_alloc_hook.ipp \
asio/impl/io_service.hpp \
asio/impl/io_service.ipp \
asio/impl/io_context.hpp \
asio/impl/io_context.ipp \
asio/impl/post.hpp \
asio/impl/read_at.hpp \
asio/impl/read.hpp \
@ -319,6 +319,8 @@ nobase_include_HEADERS = \
asio/impl/use_future.hpp \
asio/impl/write_at.hpp \
asio/impl/write.hpp \
asio/io_context_strand.hpp \
asio/io_context.hpp \
asio/io_service_strand.hpp \
asio/io_service.hpp \
asio/ip/address.hpp \
@ -432,7 +434,7 @@ nobase_include_HEADERS = \
asio/ts/buffer.hpp \
asio/ts/executor.hpp \
asio/ts/internet.hpp \
asio/ts/io_service.hpp \
asio/ts/io_context.hpp \
asio/ts/networking.hpp \
asio/ts/socket.hpp \
asio/ts/thread_pool.hpp \

View File

@ -62,6 +62,8 @@
#include "asio/handler_continuation_hook.hpp"
#include "asio/handler_invoke_hook.hpp"
#include "asio/handler_type.hpp"
#include "asio/io_context.hpp"
#include "asio/io_context_strand.hpp"
#include "asio/io_service.hpp"
#include "asio/io_service_strand.hpp"
#include "asio/ip/address.hpp"

View File

@ -57,12 +57,12 @@ public:
* This constructor creates a datagram socket without opening it. The open()
* function must be called before data can be sent or received on the socket.
*
* @param io_service The io_service object that the datagram socket will use
* @param io_context The io_context object that the datagram socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*/
explicit basic_datagram_socket(asio::io_service& io_service)
: basic_socket<Protocol, DatagramSocketService>(io_service)
explicit basic_datagram_socket(asio::io_context& io_context)
: basic_socket<Protocol, DatagramSocketService>(io_context)
{
}
@ -70,7 +70,7 @@ public:
/**
* This constructor creates and opens a datagram socket.
*
* @param io_service The io_service object that the datagram socket will use
* @param io_context The io_context object that the datagram socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*
@ -78,9 +78,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_datagram_socket(asio::io_service& io_service,
basic_datagram_socket(asio::io_context& io_context,
const protocol_type& protocol)
: basic_socket<Protocol, DatagramSocketService>(io_service, protocol)
: basic_socket<Protocol, DatagramSocketService>(io_context, protocol)
{
}
@ -91,7 +91,7 @@ public:
* to the specified endpoint on the local machine. The protocol used is the
* protocol associated with the given endpoint.
*
* @param io_service The io_service object that the datagram socket will use
* @param io_context The io_context object that the datagram socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*
@ -100,9 +100,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_datagram_socket(asio::io_service& io_service,
basic_datagram_socket(asio::io_context& io_context,
const endpoint_type& endpoint)
: basic_socket<Protocol, DatagramSocketService>(io_service, endpoint)
: basic_socket<Protocol, DatagramSocketService>(io_context, endpoint)
{
}
@ -111,7 +111,7 @@ public:
* This constructor creates a datagram socket object to hold an existing
* native socket.
*
* @param io_service The io_service object that the datagram socket will use
* @param io_context The io_context object that the datagram socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*
@ -121,10 +121,10 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_datagram_socket(asio::io_service& io_service,
basic_datagram_socket(asio::io_context& io_context,
const protocol_type& protocol, const native_handle_type& native_socket)
: basic_socket<Protocol, DatagramSocketService>(
io_service, protocol, native_socket)
io_context, protocol, native_socket)
{
}
@ -137,7 +137,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_datagram_socket(io_service&) constructor.
* constructed using the @c basic_datagram_socket(io_context&) constructor.
*/
basic_datagram_socket(basic_datagram_socket&& other)
: basic_socket<Protocol, DatagramSocketService>(
@ -154,7 +154,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_datagram_socket(io_service&) constructor.
* constructed using the @c basic_datagram_socket(io_context&) constructor.
*/
basic_datagram_socket& operator=(basic_datagram_socket&& other)
{
@ -172,7 +172,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_datagram_socket(io_service&) constructor.
* constructed using the @c basic_datagram_socket(io_context&) constructor.
*/
template <typename Protocol1, typename DatagramSocketService1>
basic_datagram_socket(
@ -194,7 +194,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_datagram_socket(io_service&) constructor.
* constructed using the @c basic_datagram_socket(io_context&) constructor.
*/
template <typename Protocol1, typename DatagramSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
@ -313,7 +313,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_send operation can only be used with a connected socket.
* Use the async_send_to function to send data on an unconnected datagram
@ -364,7 +364,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_send operation can only be used with a connected socket.
* Use the async_send_to function to send data on an unconnected datagram
@ -496,7 +496,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To send a single data buffer use the @ref buffer function as follows:
@ -551,7 +551,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename ConstBufferSequence, typename WriteHandler>
ASIO_INITFN_RESULT_TYPE(WriteHandler,
@ -678,7 +678,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_receive operation can only be used with a connected socket.
* Use the async_receive_from function to receive data on an unconnected
@ -730,7 +730,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_receive operation can only be used with a connected socket.
* Use the async_receive_from function to receive data on an unconnected
@ -865,7 +865,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To receive into a single data buffer use the @ref buffer function as
@ -919,7 +919,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename MutableBufferSequence, typename ReadHandler>
ASIO_INITFN_RESULT_TYPE(ReadHandler,

View File

@ -50,7 +50,7 @@ namespace asio {
* Performing a blocking wait:
* @code
* // Construct a timer without setting an expiry time.
* asio::deadline_timer timer(io_service);
* asio::deadline_timer timer(io_context);
*
* // Set an expiry time relative to now.
* timer.expires_from_now(boost::posix_time::seconds(5));
@ -73,7 +73,7 @@ namespace asio {
* ...
*
* // Construct a timer with an absolute expiry time.
* asio::deadline_timer timer(io_service,
* asio::deadline_timer timer(io_context,
* boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
*
* // Start an asynchronous wait.
@ -141,11 +141,11 @@ public:
* expires_at() or expires_from_now() functions must be called to set an
* expiry time before the timer can be waited on.
*
* @param io_service The io_service object that the timer will use to dispatch
* @param io_context The io_context object that the timer will use to dispatch
* handlers for any asynchronous operations performed on the timer.
*/
explicit basic_deadline_timer(asio::io_service& io_service)
: basic_io_object<TimerService>(io_service)
explicit basic_deadline_timer(asio::io_context& io_context)
: basic_io_object<TimerService>(io_context)
{
}
@ -153,15 +153,15 @@ public:
/**
* This constructor creates a timer and sets the expiry time.
*
* @param io_service The io_service object that the timer will use to dispatch
* @param io_context The io_context object that the timer will use to dispatch
* handlers for any asynchronous operations performed on the timer.
*
* @param expiry_time The expiry time to be used for the timer, expressed
* as an absolute time.
*/
basic_deadline_timer(asio::io_service& io_service,
basic_deadline_timer(asio::io_context& io_context,
const time_type& expiry_time)
: basic_io_object<TimerService>(io_service)
: basic_io_object<TimerService>(io_context)
{
asio::error_code ec;
this->get_service().expires_at(this->get_implementation(), expiry_time, ec);
@ -172,15 +172,15 @@ public:
/**
* This constructor creates a timer and sets the expiry time.
*
* @param io_service The io_service object that the timer will use to dispatch
* @param io_context The io_context object that the timer will use to dispatch
* handlers for any asynchronous operations performed on the timer.
*
* @param expiry_time The expiry time to be used for the timer, relative to
* now.
*/
basic_deadline_timer(asio::io_service& io_service,
basic_deadline_timer(asio::io_context& io_context,
const duration_type& expiry_time)
: basic_io_object<TimerService>(io_service)
: basic_io_object<TimerService>(io_context)
{
asio::error_code ec;
this->get_service().expires_from_now(
@ -495,7 +495,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename WaitHandler>
ASIO_INITFN_RESULT_TYPE(WaitHandler,

View File

@ -16,7 +16,7 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -67,28 +67,42 @@ public:
typedef typename service_type::implementation_type implementation_type;
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use get_executor().) Get the io_service associated with the
/// (Deprecated: Use get_executor().) Get the io_context associated with the
/// object.
/**
* This function may be used to obtain the io_service object that the I/O
* This function may be used to obtain the io_context object that the I/O
* object uses to dispatch handlers for asynchronous operations.
*
* @return A reference to the io_service object that the I/O object will use
* @return A reference to the io_context object that the I/O object will use
* to dispatch handlers. Ownership is not transferred to the caller.
*/
asio::io_service& get_io_service()
asio::io_context& get_io_context()
{
return service_.get_io_service();
return service_.get_io_context();
}
/// (Deprecated: Use get_executor().) Get the io_context associated with the
/// object.
/**
* This function may be used to obtain the io_context object that the I/O
* object uses to dispatch handlers for asynchronous operations.
*
* @return A reference to the io_context object that the I/O object will use
* to dispatch handlers. Ownership is not transferred to the caller.
*/
asio::io_context& get_io_service()
{
return service_.get_io_context();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// The type of the executor associated with the object.
typedef asio::io_service::executor_type executor_type;
typedef asio::io_context::executor_type executor_type;
/// Get the executor associated with the object.
executor_type get_executor() ASIO_NOEXCEPT
{
return service_.get_io_service().get_executor();
return service_.get_io_context().get_executor();
}
protected:
@ -97,8 +111,8 @@ protected:
* Performs:
* @code get_service().construct(get_implementation()); @endcode
*/
explicit basic_io_object(asio::io_service& io_service)
: service_(asio::use_service<IoObjectService>(io_service))
explicit basic_io_object(asio::io_context& io_context)
: service_(asio::use_service<IoObjectService>(io_context))
{
service_.construct(implementation_);
}
@ -180,22 +194,27 @@ public:
typedef typename service_type::implementation_type implementation_type;
#if !defined(ASIO_NO_DEPRECATED)
asio::io_service& get_io_service()
asio::io_context& get_io_context()
{
return service_->get_io_service();
return service_->get_io_context();
}
asio::io_context& get_io_service()
{
return service_->get_io_context();
}
#endif // !defined(ASIO_NO_DEPRECATED)
typedef asio::io_service::executor_type executor_type;
typedef asio::io_context::executor_type executor_type;
executor_type get_executor() ASIO_NOEXCEPT
{
return service_->get_io_service().get_executor();
return service_->get_io_context().get_executor();
}
protected:
explicit basic_io_object(asio::io_service& io_service)
: service_(&asio::use_service<IoObjectService>(io_service))
explicit basic_io_object(asio::io_context& io_context)
: service_(&asio::use_service<IoObjectService>(io_context))
{
service_->construct(implementation_);
}

View File

@ -57,12 +57,12 @@ public:
* This constructor creates a raw socket without opening it. The open()
* function must be called before data can be sent or received on the socket.
*
* @param io_service The io_service object that the raw socket will use
* @param io_context The io_context object that the raw socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*/
explicit basic_raw_socket(asio::io_service& io_service)
: basic_socket<Protocol, RawSocketService>(io_service)
explicit basic_raw_socket(asio::io_context& io_context)
: basic_socket<Protocol, RawSocketService>(io_context)
{
}
@ -70,7 +70,7 @@ public:
/**
* This constructor creates and opens a raw socket.
*
* @param io_service The io_service object that the raw socket will use
* @param io_context The io_context object that the raw socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*
@ -78,9 +78,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_raw_socket(asio::io_service& io_service,
basic_raw_socket(asio::io_context& io_context,
const protocol_type& protocol)
: basic_socket<Protocol, RawSocketService>(io_service, protocol)
: basic_socket<Protocol, RawSocketService>(io_context, protocol)
{
}
@ -91,7 +91,7 @@ public:
* to the specified endpoint on the local machine. The protocol used is the
* protocol associated with the given endpoint.
*
* @param io_service The io_service object that the raw socket will use
* @param io_context The io_context object that the raw socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*
@ -100,9 +100,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_raw_socket(asio::io_service& io_service,
basic_raw_socket(asio::io_context& io_context,
const endpoint_type& endpoint)
: basic_socket<Protocol, RawSocketService>(io_service, endpoint)
: basic_socket<Protocol, RawSocketService>(io_context, endpoint)
{
}
@ -111,7 +111,7 @@ public:
* This constructor creates a raw socket object to hold an existing
* native socket.
*
* @param io_service The io_service object that the raw socket will use
* @param io_context The io_context object that the raw socket will use
* to dispatch handlers for any asynchronous operations performed on the
* socket.
*
@ -121,10 +121,10 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_raw_socket(asio::io_service& io_service,
basic_raw_socket(asio::io_context& io_context,
const protocol_type& protocol, const native_handle_type& native_socket)
: basic_socket<Protocol, RawSocketService>(
io_service, protocol, native_socket)
io_context, protocol, native_socket)
{
}
@ -137,7 +137,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_raw_socket(io_service&) constructor.
* constructed using the @c basic_raw_socket(io_context&) constructor.
*/
basic_raw_socket(basic_raw_socket&& other)
: basic_socket<Protocol, RawSocketService>(
@ -153,7 +153,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_raw_socket(io_service&) constructor.
* constructed using the @c basic_raw_socket(io_context&) constructor.
*/
basic_raw_socket& operator=(basic_raw_socket&& other)
{
@ -170,7 +170,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_raw_socket(io_service&) constructor.
* constructed using the @c basic_raw_socket(io_context&) constructor.
*/
template <typename Protocol1, typename RawSocketService1>
basic_raw_socket(basic_raw_socket<Protocol1, RawSocketService1>&& other,
@ -189,7 +189,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_raw_socket(io_service&) constructor.
* constructed using the @c basic_raw_socket(io_context&) constructor.
*/
template <typename Protocol1, typename RawSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
@ -305,7 +305,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_send operation can only be used with a connected socket.
* Use the async_send_to function to send data on an unconnected raw
@ -356,7 +356,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_send operation can only be used with a connected socket.
* Use the async_send_to function to send data on an unconnected raw
@ -488,7 +488,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To send a single data buffer use the @ref buffer function as follows:
@ -542,7 +542,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename ConstBufferSequence, typename WriteHandler>
ASIO_INITFN_RESULT_TYPE(WriteHandler,
@ -669,7 +669,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_receive operation can only be used with a connected socket.
* Use the async_receive_from function to receive data on an unconnected
@ -721,7 +721,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The async_receive operation can only be used with a connected socket.
* Use the async_receive_from function to receive data on an unconnected
@ -856,7 +856,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To receive into a single data buffer use the @ref buffer function as
@ -910,7 +910,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename MutableBufferSequence, typename ReadHandler>
ASIO_INITFN_RESULT_TYPE(ReadHandler,

View File

@ -58,12 +58,12 @@ public:
* socket needs to be opened and then connected or accepted before data can
* be sent or received on it.
*
* @param io_service The io_service object that the sequenced packet socket
* @param io_context The io_context object that the sequenced packet socket
* will use to dispatch handlers for any asynchronous operations performed on
* the socket.
*/
explicit basic_seq_packet_socket(asio::io_service& io_service)
: basic_socket<Protocol, SeqPacketSocketService>(io_service)
explicit basic_seq_packet_socket(asio::io_context& io_context)
: basic_socket<Protocol, SeqPacketSocketService>(io_context)
{
}
@ -73,7 +73,7 @@ public:
* needs to be connected or accepted before data can be sent or received on
* it.
*
* @param io_service The io_service object that the sequenced packet socket
* @param io_context The io_context object that the sequenced packet socket
* will use to dispatch handlers for any asynchronous operations performed on
* the socket.
*
@ -81,9 +81,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_seq_packet_socket(asio::io_service& io_service,
basic_seq_packet_socket(asio::io_context& io_context,
const protocol_type& protocol)
: basic_socket<Protocol, SeqPacketSocketService>(io_service, protocol)
: basic_socket<Protocol, SeqPacketSocketService>(io_context, protocol)
{
}
@ -94,7 +94,7 @@ public:
* it bound to the specified endpoint on the local machine. The protocol used
* is the protocol associated with the given endpoint.
*
* @param io_service The io_service object that the sequenced packet socket
* @param io_context The io_context object that the sequenced packet socket
* will use to dispatch handlers for any asynchronous operations performed on
* the socket.
*
@ -103,9 +103,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_seq_packet_socket(asio::io_service& io_service,
basic_seq_packet_socket(asio::io_context& io_context,
const endpoint_type& endpoint)
: basic_socket<Protocol, SeqPacketSocketService>(io_service, endpoint)
: basic_socket<Protocol, SeqPacketSocketService>(io_context, endpoint)
{
}
@ -114,7 +114,7 @@ public:
* This constructor creates a sequenced packet socket object to hold an
* existing native socket.
*
* @param io_service The io_service object that the sequenced packet socket
* @param io_context The io_context object that the sequenced packet socket
* will use to dispatch handlers for any asynchronous operations performed on
* the socket.
*
@ -124,10 +124,10 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_seq_packet_socket(asio::io_service& io_service,
basic_seq_packet_socket(asio::io_context& io_context,
const protocol_type& protocol, const native_handle_type& native_socket)
: basic_socket<Protocol, SeqPacketSocketService>(
io_service, protocol, native_socket)
io_context, protocol, native_socket)
{
}
@ -141,7 +141,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
* constructed using the @c basic_seq_packet_socket(io_context&) constructor.
*/
basic_seq_packet_socket(basic_seq_packet_socket&& other)
: basic_socket<Protocol, SeqPacketSocketService>(
@ -158,7 +158,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
* constructed using the @c basic_seq_packet_socket(io_context&) constructor.
*/
basic_seq_packet_socket& operator=(basic_seq_packet_socket&& other)
{
@ -177,7 +177,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
* constructed using the @c basic_seq_packet_socket(io_context&) constructor.
*/
template <typename Protocol1, typename SeqPacketSocketService1>
basic_seq_packet_socket(
@ -199,7 +199,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
* constructed using the @c basic_seq_packet_socket(io_context&) constructor.
*/
template <typename Protocol1, typename SeqPacketSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
@ -295,7 +295,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To send a single data buffer use the @ref buffer function as follows:
@ -466,7 +466,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To receive into a single data buffer use the @ref buffer function as
@ -522,7 +522,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To receive into a single data buffer use the @ref buffer function as

View File

@ -58,11 +58,11 @@ public:
/**
* This constructor creates a serial port without opening it.
*
* @param io_service The io_service object that the serial port will use to
* @param io_context The io_context object that the serial port will use to
* dispatch handlers for any asynchronous operations performed on the port.
*/
explicit basic_serial_port(asio::io_service& io_service)
: basic_io_object<SerialPortService>(io_service)
explicit basic_serial_port(asio::io_context& io_context)
: basic_io_object<SerialPortService>(io_context)
{
}
@ -71,15 +71,15 @@ public:
* This constructor creates and opens a serial port for the specified device
* name.
*
* @param io_service The io_service object that the serial port will use to
* @param io_context The io_context object that the serial port will use to
* dispatch handlers for any asynchronous operations performed on the port.
*
* @param device The platform-specific device name for this serial
* port.
*/
explicit basic_serial_port(asio::io_service& io_service,
explicit basic_serial_port(asio::io_context& io_context,
const char* device)
: basic_io_object<SerialPortService>(io_service)
: basic_io_object<SerialPortService>(io_context)
{
asio::error_code ec;
this->get_service().open(this->get_implementation(), device, ec);
@ -91,15 +91,15 @@ public:
* This constructor creates and opens a serial port for the specified device
* name.
*
* @param io_service The io_service object that the serial port will use to
* @param io_context The io_context object that the serial port will use to
* dispatch handlers for any asynchronous operations performed on the port.
*
* @param device The platform-specific device name for this serial
* port.
*/
explicit basic_serial_port(asio::io_service& io_service,
explicit basic_serial_port(asio::io_context& io_context,
const std::string& device)
: basic_io_object<SerialPortService>(io_service)
: basic_io_object<SerialPortService>(io_context)
{
asio::error_code ec;
this->get_service().open(this->get_implementation(), device, ec);
@ -111,16 +111,16 @@ public:
* This constructor creates a serial port object to hold an existing native
* serial port.
*
* @param io_service The io_service object that the serial port will use to
* @param io_context The io_context object that the serial port will use to
* dispatch handlers for any asynchronous operations performed on the port.
*
* @param native_serial_port A native serial port.
*
* @throws asio::system_error Thrown on failure.
*/
basic_serial_port(asio::io_service& io_service,
basic_serial_port(asio::io_context& io_context,
const native_handle_type& native_serial_port)
: basic_io_object<SerialPortService>(io_service)
: basic_io_object<SerialPortService>(io_context)
{
asio::error_code ec;
this->get_service().assign(this->get_implementation(),
@ -137,7 +137,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_serial_port(io_service&) constructor.
* constructed using the @c basic_serial_port(io_context&) constructor.
*/
basic_serial_port(basic_serial_port&& other)
: basic_io_object<SerialPortService>(
@ -153,7 +153,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_serial_port(io_service&) constructor.
* constructed using the @c basic_serial_port(io_context&) constructor.
*/
basic_serial_port& operator=(basic_serial_port&& other)
{
@ -526,7 +526,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The write operation may not transmit all of the data to the peer.
* Consider using the @ref async_write function if you need to ensure that all
@ -638,7 +638,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The read operation may not read all of the requested number of bytes.
* Consider using the @ref async_read function if you need to ensure that the

View File

@ -54,7 +54,7 @@ namespace asio {
* ...
*
* // Construct a signal set registered for process termination.
* asio::signal_set signals(io_service, SIGINT, SIGTERM);
* asio::signal_set signals(io_context, SIGINT, SIGTERM);
*
* // Start an asynchronous wait for one of the signals to occur.
* signals.async_wait(handler);
@ -98,11 +98,11 @@ public:
/**
* This constructor creates a signal set without registering for any signals.
*
* @param io_service The io_service object that the signal set will use to
* @param io_context The io_context object that the signal set will use to
* dispatch handlers for any asynchronous operations performed on the set.
*/
explicit basic_signal_set(asio::io_service& io_service)
: basic_io_object<SignalSetService>(io_service)
explicit basic_signal_set(asio::io_context& io_context)
: basic_io_object<SignalSetService>(io_context)
{
}
@ -110,17 +110,17 @@ public:
/**
* This constructor creates a signal set and registers for one signal.
*
* @param io_service The io_service object that the signal set will use to
* @param io_context The io_context object that the signal set will use to
* dispatch handlers for any asynchronous operations performed on the set.
*
* @param signal_number_1 The signal number to be added.
*
* @note This constructor is equivalent to performing:
* @code asio::signal_set signals(io_service);
* @code asio::signal_set signals(io_context);
* signals.add(signal_number_1); @endcode
*/
basic_signal_set(asio::io_service& io_service, int signal_number_1)
: basic_io_object<SignalSetService>(io_service)
basic_signal_set(asio::io_context& io_context, int signal_number_1)
: basic_io_object<SignalSetService>(io_context)
{
asio::error_code ec;
this->get_service().add(this->get_implementation(), signal_number_1, ec);
@ -131,7 +131,7 @@ public:
/**
* This constructor creates a signal set and registers for two signals.
*
* @param io_service The io_service object that the signal set will use to
* @param io_context The io_context object that the signal set will use to
* dispatch handlers for any asynchronous operations performed on the set.
*
* @param signal_number_1 The first signal number to be added.
@ -139,13 +139,13 @@ public:
* @param signal_number_2 The second signal number to be added.
*
* @note This constructor is equivalent to performing:
* @code asio::signal_set signals(io_service);
* @code asio::signal_set signals(io_context);
* signals.add(signal_number_1);
* signals.add(signal_number_2); @endcode
*/
basic_signal_set(asio::io_service& io_service, int signal_number_1,
basic_signal_set(asio::io_context& io_context, int signal_number_1,
int signal_number_2)
: basic_io_object<SignalSetService>(io_service)
: basic_io_object<SignalSetService>(io_context)
{
asio::error_code ec;
this->get_service().add(this->get_implementation(), signal_number_1, ec);
@ -158,7 +158,7 @@ public:
/**
* This constructor creates a signal set and registers for three signals.
*
* @param io_service The io_service object that the signal set will use to
* @param io_context The io_context object that the signal set will use to
* dispatch handlers for any asynchronous operations performed on the set.
*
* @param signal_number_1 The first signal number to be added.
@ -168,14 +168,14 @@ public:
* @param signal_number_3 The third signal number to be added.
*
* @note This constructor is equivalent to performing:
* @code asio::signal_set signals(io_service);
* @code asio::signal_set signals(io_context);
* signals.add(signal_number_1);
* signals.add(signal_number_2);
* signals.add(signal_number_3); @endcode
*/
basic_signal_set(asio::io_service& io_service, int signal_number_1,
basic_signal_set(asio::io_context& io_context, int signal_number_1,
int signal_number_2, int signal_number_3)
: basic_io_object<SignalSetService>(io_service)
: basic_io_object<SignalSetService>(io_context)
{
asio::error_code ec;
this->get_service().add(this->get_implementation(), signal_number_1, ec);
@ -363,7 +363,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename SignalHandler>
ASIO_INITFN_RESULT_TYPE(SignalHandler,

View File

@ -60,11 +60,11 @@ public:
/**
* This constructor creates a socket without opening it.
*
* @param io_service The io_service object that the socket will use to
* @param io_context The io_context object that the socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*/
explicit basic_socket(asio::io_service& io_service)
: basic_io_object<SocketService>(io_service)
explicit basic_socket(asio::io_context& io_context)
: basic_io_object<SocketService>(io_context)
{
}
@ -72,16 +72,16 @@ public:
/**
* This constructor creates and opens a socket.
*
* @param io_service The io_service object that the socket will use to
* @param io_context The io_context object that the socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*
* @param protocol An object specifying protocol parameters to be used.
*
* @throws asio::system_error Thrown on failure.
*/
basic_socket(asio::io_service& io_service,
basic_socket(asio::io_context& io_context,
const protocol_type& protocol)
: basic_io_object<SocketService>(io_service)
: basic_io_object<SocketService>(io_context)
{
asio::error_code ec;
this->get_service().open(this->get_implementation(), protocol, ec);
@ -95,7 +95,7 @@ public:
* specified endpoint on the local machine. The protocol used is the protocol
* associated with the given endpoint.
*
* @param io_service The io_service object that the socket will use to
* @param io_context The io_context object that the socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*
* @param endpoint An endpoint on the local machine to which the socket will
@ -103,9 +103,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_socket(asio::io_service& io_service,
basic_socket(asio::io_context& io_context,
const endpoint_type& endpoint)
: basic_io_object<SocketService>(io_service)
: basic_io_object<SocketService>(io_context)
{
asio::error_code ec;
const protocol_type protocol = endpoint.protocol();
@ -119,7 +119,7 @@ public:
/**
* This constructor creates a socket object to hold an existing native socket.
*
* @param io_service The io_service object that the socket will use to
* @param io_context The io_context object that the socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*
* @param protocol An object specifying protocol parameters to be used.
@ -128,9 +128,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_socket(asio::io_service& io_service,
basic_socket(asio::io_context& io_context,
const protocol_type& protocol, const native_handle_type& native_socket)
: basic_io_object<SocketService>(io_service)
: basic_io_object<SocketService>(io_context)
{
asio::error_code ec;
this->get_service().assign(this->get_implementation(),
@ -147,7 +147,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
* constructed using the @c basic_socket(io_context&) constructor.
*/
basic_socket(basic_socket&& other)
: basic_io_object<SocketService>(
@ -163,7 +163,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
* constructed using the @c basic_socket(io_context&) constructor.
*/
basic_socket& operator=(basic_socket&& other)
{
@ -184,12 +184,12 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
* constructed using the @c basic_socket(io_context&) constructor.
*/
template <typename Protocol1, typename SocketService1>
basic_socket(basic_socket<Protocol1, SocketService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_io_object<SocketService>(other.get_service().get_io_service())
: basic_io_object<SocketService>(other.get_service().get_io_context())
{
this->get_service().template converting_move_construct<Protocol1>(
this->get_implementation(), other.get_implementation());
@ -203,7 +203,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
* constructed using the @c basic_socket(io_context&) constructor.
*/
template <typename Protocol1, typename SocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
@ -256,7 +256,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* socket.open(asio::ip::tcp::v4());
* @endcode
*/
@ -277,7 +277,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* asio::error_code ec;
* socket.open(asio::ip::tcp::v4(), ec);
* if (ec)
@ -364,7 +364,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::error_code ec;
* socket.close(ec);
@ -566,7 +566,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* socket.open(asio::ip::tcp::v4());
* socket.bind(asio::ip::tcp::endpoint(
* asio::ip::tcp::v4(), 12345));
@ -591,7 +591,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* socket.open(asio::ip::tcp::v4());
* asio::error_code ec;
* socket.bind(asio::ip::tcp::endpoint(
@ -625,7 +625,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* asio::ip::tcp::endpoint endpoint(
* asio::ip::address::from_string("1.2.3.4"), 12345);
* socket.connect(endpoint);
@ -661,7 +661,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* asio::ip::tcp::endpoint endpoint(
* asio::ip::address::from_string("1.2.3.4"), 12345);
* asio::error_code ec;
@ -709,7 +709,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -723,7 +723,7 @@ public:
*
* ...
*
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* asio::ip::tcp::endpoint endpoint(
* asio::ip::address::from_string("1.2.3.4"), 12345);
* socket.async_connect(endpoint, connect_handler);
@ -790,7 +790,7 @@ public:
* @par Example
* Setting the IPPROTO_TCP/TCP_NODELAY option:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::no_delay option(true);
* socket.set_option(option);
@ -832,7 +832,7 @@ public:
* @par Example
* Setting the IPPROTO_TCP/TCP_NODELAY option:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::no_delay option(true);
* asio::error_code ec;
@ -879,7 +879,7 @@ public:
* @par Example
* Getting the value of the SOL_SOCKET/SO_KEEPALIVE option:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::socket::keep_alive option;
* socket.get_option(option);
@ -922,7 +922,7 @@ public:
* @par Example
* Getting the value of the SOL_SOCKET/SO_KEEPALIVE option:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::socket::keep_alive option;
* asio::error_code ec;
@ -957,7 +957,7 @@ public:
* @par Example
* Getting the number of bytes ready to read:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::socket::bytes_readable command;
* socket.io_control(command);
@ -987,7 +987,7 @@ public:
* @par Example
* Getting the number of bytes ready to read:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::socket::bytes_readable command;
* asio::error_code ec;
@ -1347,7 +1347,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::endpoint endpoint = socket.local_endpoint();
* @endcode
@ -1372,7 +1372,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::error_code ec;
* asio::ip::tcp::endpoint endpoint = socket.local_endpoint(ec);
@ -1397,7 +1397,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::endpoint endpoint = socket.remote_endpoint();
* @endcode
@ -1422,7 +1422,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::error_code ec;
* asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(ec);
@ -1449,7 +1449,7 @@ public:
* @par Example
* Shutting down the send side of the socket:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* socket.shutdown(asio::ip::tcp::socket::shutdown_send);
* @endcode
@ -1473,7 +1473,7 @@ public:
* @par Example
* Shutting down the send side of the socket:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::error_code ec;
* socket.shutdown(asio::ip::tcp::socket::shutdown_send, ec);
@ -1500,7 +1500,7 @@ public:
* @par Example
* Waiting for a socket to become readable.
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* socket.wait(asio::ip::tcp::socket::wait_read);
* @endcode
@ -1525,7 +1525,7 @@ public:
* @par Example
* Waiting for a socket to become readable.
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::error_code ec;
* socket.wait(asio::ip::tcp::socket::wait_read, ec);
@ -1553,7 +1553,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -1567,7 +1567,7 @@ public:
*
* ...
*
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* socket.async_wait(asio::ip::tcp::socket::wait_read, wait_handler);
* @endcode

View File

@ -41,7 +41,7 @@ namespace asio {
* @par Example
* Opening a socket acceptor with the SO_REUSEADDR option enabled:
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), port);
* acceptor.open(endpoint.protocol());
* acceptor.set_option(asio::ip::tcp::acceptor::reuse_address(true));
@ -71,12 +71,12 @@ public:
* connections. The open() function must be called before the acceptor can
* accept new socket connections.
*
* @param io_service The io_service object that the acceptor will use to
* @param io_context The io_context object that the acceptor will use to
* dispatch handlers for any asynchronous operations performed on the
* acceptor.
*/
explicit basic_socket_acceptor(asio::io_service& io_service)
: basic_io_object<SocketAcceptorService>(io_service)
explicit basic_socket_acceptor(asio::io_context& io_context)
: basic_io_object<SocketAcceptorService>(io_context)
{
}
@ -84,7 +84,7 @@ public:
/**
* This constructor creates an acceptor and automatically opens it.
*
* @param io_service The io_service object that the acceptor will use to
* @param io_context The io_context object that the acceptor will use to
* dispatch handlers for any asynchronous operations performed on the
* acceptor.
*
@ -92,9 +92,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_socket_acceptor(asio::io_service& io_service,
basic_socket_acceptor(asio::io_context& io_context,
const protocol_type& protocol)
: basic_io_object<SocketAcceptorService>(io_service)
: basic_io_object<SocketAcceptorService>(io_context)
{
asio::error_code ec;
this->get_service().open(this->get_implementation(), protocol, ec);
@ -106,7 +106,7 @@ public:
* This constructor creates an acceptor and automatically opens it to listen
* for new connections on the specified endpoint.
*
* @param io_service The io_service object that the acceptor will use to
* @param io_context The io_context object that the acceptor will use to
* dispatch handlers for any asynchronous operations performed on the
* acceptor.
*
@ -120,7 +120,7 @@ public:
*
* @note This constructor is equivalent to the following code:
* @code
* basic_socket_acceptor<Protocol> acceptor(io_service);
* basic_socket_acceptor<Protocol> acceptor(io_context);
* acceptor.open(endpoint.protocol());
* if (reuse_addr)
* acceptor.set_option(socket_base::reuse_address(true));
@ -128,9 +128,9 @@ public:
* acceptor.listen(listen_backlog);
* @endcode
*/
basic_socket_acceptor(asio::io_service& io_service,
basic_socket_acceptor(asio::io_context& io_context,
const endpoint_type& endpoint, bool reuse_addr = true)
: basic_io_object<SocketAcceptorService>(io_service)
: basic_io_object<SocketAcceptorService>(io_context)
{
asio::error_code ec;
const protocol_type protocol = endpoint.protocol();
@ -154,7 +154,7 @@ public:
* This constructor creates an acceptor object to hold an existing native
* acceptor.
*
* @param io_service The io_service object that the acceptor will use to
* @param io_context The io_context object that the acceptor will use to
* dispatch handlers for any asynchronous operations performed on the
* acceptor.
*
@ -164,9 +164,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_socket_acceptor(asio::io_service& io_service,
basic_socket_acceptor(asio::io_context& io_context,
const protocol_type& protocol, const native_handle_type& native_acceptor)
: basic_io_object<SocketAcceptorService>(io_service)
: basic_io_object<SocketAcceptorService>(io_context)
{
asio::error_code ec;
this->get_service().assign(this->get_implementation(),
@ -183,7 +183,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket_acceptor(io_service&) constructor.
* constructed using the @c basic_socket_acceptor(io_context&) constructor.
*/
basic_socket_acceptor(basic_socket_acceptor&& other)
: basic_io_object<SocketAcceptorService>(
@ -199,7 +199,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket_acceptor(io_service&) constructor.
* constructed using the @c basic_socket_acceptor(io_context&) constructor.
*/
basic_socket_acceptor& operator=(basic_socket_acceptor&& other)
{
@ -221,14 +221,14 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
* constructed using the @c basic_socket(io_context&) constructor.
*/
template <typename Protocol1, typename SocketAcceptorService1>
basic_socket_acceptor(
basic_socket_acceptor<Protocol1, SocketAcceptorService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_io_object<SocketAcceptorService>(
other.get_service().get_io_service())
other.get_service().get_io_context())
{
this->get_service().template converting_move_construct<Protocol1>(
this->get_implementation(), other.get_implementation());
@ -243,7 +243,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
* constructed using the @c basic_socket(io_context&) constructor.
*/
template <typename Protocol1, typename SocketAcceptorService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
@ -269,7 +269,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* acceptor.open(asio::ip::tcp::v4());
* @endcode
*/
@ -291,7 +291,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* asio::error_code ec;
* acceptor.open(asio::ip::tcp::v4(), ec);
* if (ec)
@ -360,7 +360,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), 12345);
* acceptor.open(endpoint.protocol());
* acceptor.bind(endpoint);
@ -385,7 +385,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), 12345);
* acceptor.open(endpoint.protocol());
* asio::error_code ec;
@ -431,7 +431,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::error_code ec;
* acceptor.listen(asio::socket_base::max_connections, ec);
@ -475,7 +475,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::error_code ec;
* acceptor.close(ec);
@ -544,7 +544,7 @@ public:
* @par Example
* Setting the SOL_SOCKET/SO_REUSEADDR option:
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::acceptor::reuse_address option(true);
* acceptor.set_option(option);
@ -573,7 +573,7 @@ public:
* @par Example
* Setting the SOL_SOCKET/SO_REUSEADDR option:
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::acceptor::reuse_address option(true);
* asio::error_code ec;
@ -607,7 +607,7 @@ public:
* @par Example
* Getting the value of the SOL_SOCKET/SO_REUSEADDR option:
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::acceptor::reuse_address option;
* acceptor.get_option(option);
@ -637,7 +637,7 @@ public:
* @par Example
* Getting the value of the SOL_SOCKET/SO_REUSEADDR option:
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::acceptor::reuse_address option;
* asio::error_code ec;
@ -671,7 +671,7 @@ public:
* @par Example
* Getting the number of bytes ready to read:
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::acceptor::non_blocking_io command(true);
* socket.io_control(command);
@ -699,7 +699,7 @@ public:
* @par Example
* Getting the number of bytes ready to read:
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::acceptor::non_blocking_io command(true);
* asio::error_code ec;
@ -848,7 +848,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint();
* @endcode
@ -874,7 +874,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::error_code ec;
* asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint(ec);
@ -900,7 +900,7 @@ public:
* @par Example
* Waiting for an acceptor to become readable.
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* acceptor.wait(asio::ip::tcp::acceptor::wait_read);
* @endcode
@ -925,7 +925,7 @@ public:
* @par Example
* Waiting for an acceptor to become readable.
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::error_code ec;
* acceptor.wait(asio::ip::tcp::acceptor::wait_read, ec);
@ -953,7 +953,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -967,7 +967,7 @@ public:
*
* ...
*
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* acceptor.async_wait(
* asio::ip::tcp::acceptor::wait_read,
@ -999,9 +999,9 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* acceptor.accept(socket);
* @endcode
*/
@ -1027,9 +1027,9 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* asio::error_code ec;
* acceptor.accept(socket, ec);
* if (ec)
@ -1066,7 +1066,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -1080,9 +1080,9 @@ public:
*
* ...
*
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* acceptor.async_accept(socket, accept_handler);
* @endcode
*/
@ -1118,9 +1118,9 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* asio::ip::tcp::endpoint endpoint;
* acceptor.accept(socket, endpoint);
* @endcode
@ -1151,9 +1151,9 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* asio::ip::tcp::endpoint endpoint;
* asio::error_code ec;
* acceptor.accept(socket, endpoint, ec);
@ -1196,7 +1196,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename SocketService, typename AcceptHandler>
ASIO_INITFN_RESULT_TYPE(AcceptHandler,
@ -1228,7 +1228,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(acceptor.accept());
* @endcode
@ -1259,7 +1259,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(acceptor.accept(ec));
* if (ec)
@ -1291,7 +1291,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -1306,7 +1306,7 @@ public:
*
* ...
*
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* acceptor.async_accept(accept_handler);
* @endcode
@ -1322,7 +1322,7 @@ public:
handler, typename Protocol::socket) type_check;
return this->get_service().async_accept(
this->get_implementation(), static_cast<asio::io_service*>(0),
this->get_implementation(), static_cast<asio::io_context*>(0),
static_cast<endpoint_type*>(0),
ASIO_MOVE_CAST(MoveAcceptHandler)(handler));
}
@ -1336,7 +1336,7 @@ public:
* This overload requires that the Protocol template parameter satisfy the
* AcceptableProtocol type requirements.
*
* @param io_service The io_service object to be used for the newly accepted
* @param io_context The io_context object to be used for the newly accepted
* socket.
*
* @returns A socket object representing the newly accepted connection.
@ -1345,17 +1345,17 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(acceptor.accept());
* @endcode
*/
typename Protocol::socket accept(asio::io_service& io_service)
typename Protocol::socket accept(asio::io_context& io_context)
{
asio::error_code ec;
typename Protocol::socket peer(
this->get_service().accept(this->get_implementation(),
&io_service, static_cast<endpoint_type*>(0), ec));
&io_context, static_cast<endpoint_type*>(0), ec));
asio::detail::throw_error(ec, "accept");
return peer;
}
@ -1369,7 +1369,7 @@ public:
* This overload requires that the Protocol template parameter satisfy the
* AcceptableProtocol type requirements.
*
* @param io_service The io_service object to be used for the newly accepted
* @param io_context The io_context object to be used for the newly accepted
* socket.
*
* @param ec Set to indicate what error occurred, if any.
@ -1379,9 +1379,9 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::socket socket(acceptor.accept(io_service2, ec));
* asio::ip::tcp::socket socket(acceptor.accept(io_context2, ec));
* if (ec)
* {
* // An error occurred.
@ -1389,10 +1389,10 @@ public:
* @endcode
*/
typename Protocol::socket accept(
asio::io_service& io_service, asio::error_code& ec)
asio::io_context& io_context, asio::error_code& ec)
{
return this->get_service().accept(this->get_implementation(),
&io_service, static_cast<endpoint_type*>(0), ec);
&io_context, static_cast<endpoint_type*>(0), ec);
}
/// Start an asynchronous accept.
@ -1403,7 +1403,7 @@ public:
* This overload requires that the Protocol template parameter satisfy the
* AcceptableProtocol type requirements.
*
* @param io_service The io_service object to be used for the newly accepted
* @param io_context The io_context object to be used for the newly accepted
* socket.
*
* @param handler The handler to be called when the accept operation
@ -1416,7 +1416,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -1431,15 +1431,15 @@ public:
*
* ...
*
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* acceptor.async_accept(io_service2, accept_handler);
* acceptor.async_accept(io_context2, accept_handler);
* @endcode
*/
template <typename MoveAcceptHandler>
ASIO_INITFN_RESULT_TYPE(MoveAcceptHandler,
void (asio::error_code, typename Protocol::socket))
async_accept(asio::io_service& io_service,
async_accept(asio::io_context& io_context,
ASIO_MOVE_ARG(MoveAcceptHandler) handler)
{
// If you get an error on the following line it means that your handler does
@ -1448,7 +1448,7 @@ public:
handler, typename Protocol::socket) type_check;
return this->get_service().async_accept(this->get_implementation(),
&io_service, static_cast<endpoint_type*>(0),
&io_context, static_cast<endpoint_type*>(0),
ASIO_MOVE_CAST(MoveAcceptHandler)(handler));
}
@ -1470,7 +1470,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::endpoint endpoint;
* asio::ip::tcp::socket socket(acceptor.accept(endpoint));
@ -1481,7 +1481,7 @@ public:
asio::error_code ec;
typename Protocol::socket peer(
this->get_service().accept(this->get_implementation(),
static_cast<asio::io_service*>(0), &peer_endpoint, ec));
static_cast<asio::io_context*>(0), &peer_endpoint, ec));
asio::detail::throw_error(ec, "accept");
return peer;
}
@ -1505,7 +1505,7 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::endpoint endpoint;
* asio::ip::tcp::socket socket(acceptor.accept(endpoint, ec));
@ -1519,7 +1519,7 @@ public:
endpoint_type& peer_endpoint, asio::error_code& ec)
{
return this->get_service().accept(this->get_implementation(),
static_cast<asio::io_service*>(0), &peer_endpoint, ec);
static_cast<asio::io_context*>(0), &peer_endpoint, ec);
}
/// Start an asynchronous accept.
@ -1545,7 +1545,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -1560,7 +1560,7 @@ public:
*
* ...
*
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::endpoint endpoint;
* acceptor.async_accept(endpoint, accept_handler);
@ -1578,7 +1578,7 @@ public:
handler, typename Protocol::socket) type_check;
return this->get_service().async_accept(this->get_implementation(),
static_cast<asio::io_service*>(0), &peer_endpoint,
static_cast<asio::io_context*>(0), &peer_endpoint,
ASIO_MOVE_CAST(MoveAcceptHandler)(handler));
}
@ -1591,7 +1591,7 @@ public:
* This overload requires that the Protocol template parameter satisfy the
* AcceptableProtocol type requirements.
*
* @param io_service The io_service object to be used for the newly accepted
* @param io_context The io_context object to be used for the newly accepted
* socket.
*
* @param peer_endpoint An endpoint object into which the endpoint of the
@ -1603,20 +1603,20 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::endpoint endpoint;
* asio::ip::tcp::socket socket(
* acceptor.accept(io_service2, endpoint));
* acceptor.accept(io_context2, endpoint));
* @endcode
*/
typename Protocol::socket accept(
asio::io_service& io_service, endpoint_type& peer_endpoint)
asio::io_context& io_context, endpoint_type& peer_endpoint)
{
asio::error_code ec;
typename Protocol::socket peer(
this->get_service().accept(this->get_implementation(),
&io_service, &peer_endpoint, ec));
&io_context, &peer_endpoint, ec));
asio::detail::throw_error(ec, "accept");
return peer;
}
@ -1630,7 +1630,7 @@ public:
* This overload requires that the Protocol template parameter satisfy the
* AcceptableProtocol type requirements.
*
* @param io_service The io_service object to be used for the newly accepted
* @param io_context The io_context object to be used for the newly accepted
* socket.
*
* @param peer_endpoint An endpoint object into which the endpoint of the
@ -1643,22 +1643,22 @@ public:
*
* @par Example
* @code
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::endpoint endpoint;
* asio::ip::tcp::socket socket(
* acceptor.accept(io_service2, endpoint, ec));
* acceptor.accept(io_context2, endpoint, ec));
* if (ec)
* {
* // An error occurred.
* }
* @endcode
*/
typename Protocol::socket accept(asio::io_service& io_service,
typename Protocol::socket accept(asio::io_context& io_context,
endpoint_type& peer_endpoint, asio::error_code& ec)
{
return this->get_service().accept(this->get_implementation(),
&io_service, &peer_endpoint, ec);
&io_context, &peer_endpoint, ec);
}
/// Start an asynchronous accept.
@ -1669,7 +1669,7 @@ public:
* This overload requires that the Protocol template parameter satisfy the
* AcceptableProtocol type requirements.
*
* @param io_service The io_service object to be used for the newly accepted
* @param io_context The io_context object to be used for the newly accepted
* socket.
*
* @param peer_endpoint An endpoint object into which the endpoint of the
@ -1687,7 +1687,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -1702,16 +1702,16 @@ public:
*
* ...
*
* asio::ip::tcp::acceptor acceptor(io_service);
* asio::ip::tcp::acceptor acceptor(io_context);
* ...
* asio::ip::tcp::endpoint endpoint;
* acceptor.async_accept(io_service2, endpoint, accept_handler);
* acceptor.async_accept(io_context2, endpoint, accept_handler);
* @endcode
*/
template <typename MoveAcceptHandler>
ASIO_INITFN_RESULT_TYPE(MoveAcceptHandler,
void (asio::error_code, typename Protocol::socket))
async_accept(asio::io_service& io_service,
async_accept(asio::io_context& io_context,
endpoint_type& peer_endpoint,
ASIO_MOVE_ARG(MoveAcceptHandler) handler)
{
@ -1721,7 +1721,7 @@ public:
handler, typename Protocol::socket) type_check;
return this->get_service().async_accept(
this->get_implementation(), &io_service, &peer_endpoint,
this->get_implementation(), &io_context, &peer_endpoint,
ASIO_MOVE_CAST(MoveAcceptHandler)(handler));
}
#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)

View File

@ -24,7 +24,7 @@
#include "asio/deadline_timer_service.hpp"
#include "asio/detail/array.hpp"
#include "asio/detail/throw_error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/stream_socket_service.hpp"
#if defined(ASIO_HAS_BOOST_DATE_TIME)
@ -46,7 +46,7 @@
// init_buffers();
// this->basic_socket<Protocol, StreamSocketService>::close(ec_);
// typedef typename Protocol::resolver resolver_type;
// resolver_type resolver(detail::socket_streambuf_base::io_service_);
// resolver_type resolver(detail::socket_streambuf_base::io_context_);
// connect_to_endpoints(
// resolver.resolve(x1, ..., xn, ec_));
// return !ec_ ? this : 0;
@ -62,7 +62,7 @@
init_buffers(); \
this->basic_socket<Protocol, StreamSocketService>::close(ec_); \
typedef typename Protocol::resolver resolver_type; \
resolver_type resolver(detail::socket_streambuf_base::io_service_); \
resolver_type resolver(detail::socket_streambuf_base::io_context_); \
connect_to_endpoints( \
resolver.resolve(ASIO_VARIADIC_BYVAL_ARGS(n), ec_)); \
return !ec_ ? this : 0; \
@ -76,12 +76,12 @@
namespace asio {
namespace detail {
// A separate base class is used to ensure that the io_service is initialised
// A separate base class is used to ensure that the io_context is initialised
// prior to the basic_socket_streambuf's basic_socket base class.
class socket_streambuf_base
{
protected:
io_service io_service_;
io_context io_context_;
};
} // namespace detail
@ -141,7 +141,7 @@ public:
/// Construct a basic_socket_streambuf without establishing a connection.
basic_socket_streambuf()
: basic_socket<Protocol, StreamSocketService>(
this->detail::socket_streambuf_base::io_service_),
this->detail::socket_streambuf_base::io_context_),
unbuffered_(false),
timer_service_(0),
timer_state_(no_timer)
@ -184,8 +184,8 @@ public:
endpoint, handler);
ec_ = asio::error::would_block;
this->get_service().get_io_service().restart();
do this->get_service().get_io_service().run_one();
this->get_service().get_io_context().restart();
do this->get_service().get_io_context().run_one();
while (ec_ == asio::error::would_block);
return !ec_ ? this : 0;
@ -212,7 +212,7 @@ public:
init_buffers();
this->basic_socket<Protocol, StreamSocketService>::close(ec_);
typedef typename Protocol::resolver resolver_type;
resolver_type resolver(detail::socket_streambuf_base::io_service_);
resolver_type resolver(detail::socket_streambuf_base::io_context_);
connect_to_endpoints(resolver.resolve(x..., ec_));
return !ec_ ? this : 0;
}
@ -390,8 +390,8 @@ protected:
0, handler);
ec_ = asio::error::would_block;
this->get_service().get_io_service().restart();
do this->get_service().get_io_service().run_one();
this->get_service().get_io_context().restart();
do this->get_service().get_io_context().run_one();
while (ec_ == asio::error::would_block);
if (ec_)
return traits_type::eof();
@ -430,8 +430,8 @@ protected:
asio::buffer(&ch, sizeof(char_type)), 0, handler);
ec_ = asio::error::would_block;
this->get_service().get_io_service().restart();
do this->get_service().get_io_service().run_one();
this->get_service().get_io_context().restart();
do this->get_service().get_io_context().run_one();
while (ec_ == asio::error::would_block);
if (ec_)
return traits_type::eof();
@ -457,8 +457,8 @@ protected:
asio::buffer(buffer), 0, handler);
ec_ = asio::error::would_block;
this->get_service().get_io_service().restart();
do this->get_service().get_io_service().run_one();
this->get_service().get_io_context().restart();
do this->get_service().get_io_context().run_one();
while (ec_ == asio::error::would_block);
if (ec_)
return traits_type::eof();
@ -540,8 +540,8 @@ private:
*i, handler);
ec_ = asio::error::would_block;
this->get_service().get_io_service().restart();
do this->get_service().get_io_service().run_one();
this->get_service().get_io_context().restart();
do this->get_service().get_io_context().run_one();
while (ec_ == asio::error::would_block);
++i;
@ -600,7 +600,7 @@ private:
if (timer_service_ == 0)
{
TimerService& timer_service = use_service<TimerService>(
detail::socket_streambuf_base::io_service_);
detail::socket_streambuf_base::io_context_);
timer_service.construct(timer_implementation_);
timer_service_ = &timer_service;
}

View File

@ -61,11 +61,11 @@ public:
* needs to be opened and then connected or accepted before data can be sent
* or received on it.
*
* @param io_service The io_service object that the stream socket will use to
* @param io_context The io_context object that the stream socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*/
explicit basic_stream_socket(asio::io_service& io_service)
: basic_socket<Protocol, StreamSocketService>(io_service)
explicit basic_stream_socket(asio::io_context& io_context)
: basic_socket<Protocol, StreamSocketService>(io_context)
{
}
@ -74,16 +74,16 @@ public:
* This constructor creates and opens a stream socket. The socket needs to be
* connected or accepted before data can be sent or received on it.
*
* @param io_service The io_service object that the stream socket will use to
* @param io_context The io_context object that the stream socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*
* @param protocol An object specifying protocol parameters to be used.
*
* @throws asio::system_error Thrown on failure.
*/
basic_stream_socket(asio::io_service& io_service,
basic_stream_socket(asio::io_context& io_context,
const protocol_type& protocol)
: basic_socket<Protocol, StreamSocketService>(io_service, protocol)
: basic_socket<Protocol, StreamSocketService>(io_context, protocol)
{
}
@ -94,7 +94,7 @@ public:
* to the specified endpoint on the local machine. The protocol used is the
* protocol associated with the given endpoint.
*
* @param io_service The io_service object that the stream socket will use to
* @param io_context The io_context object that the stream socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*
* @param endpoint An endpoint on the local machine to which the stream
@ -102,9 +102,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_stream_socket(asio::io_service& io_service,
basic_stream_socket(asio::io_context& io_context,
const endpoint_type& endpoint)
: basic_socket<Protocol, StreamSocketService>(io_service, endpoint)
: basic_socket<Protocol, StreamSocketService>(io_context, endpoint)
{
}
@ -113,7 +113,7 @@ public:
* This constructor creates a stream socket object to hold an existing native
* socket.
*
* @param io_service The io_service object that the stream socket will use to
* @param io_context The io_context object that the stream socket will use to
* dispatch handlers for any asynchronous operations performed on the socket.
*
* @param protocol An object specifying protocol parameters to be used.
@ -122,10 +122,10 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_stream_socket(asio::io_service& io_service,
basic_stream_socket(asio::io_context& io_context,
const protocol_type& protocol, const native_handle_type& native_socket)
: basic_socket<Protocol, StreamSocketService>(
io_service, protocol, native_socket)
io_context, protocol, native_socket)
{
}
@ -138,7 +138,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_socket(io_service&) constructor.
* constructed using the @c basic_stream_socket(io_context&) constructor.
*/
basic_stream_socket(basic_stream_socket&& other)
: basic_socket<Protocol, StreamSocketService>(
@ -154,7 +154,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_socket(io_service&) constructor.
* constructed using the @c basic_stream_socket(io_context&) constructor.
*/
basic_stream_socket& operator=(basic_stream_socket&& other)
{
@ -172,7 +172,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_socket(io_service&) constructor.
* constructed using the @c basic_stream_socket(io_context&) constructor.
*/
template <typename Protocol1, typename StreamSocketService1>
basic_stream_socket(
@ -192,7 +192,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_socket(io_service&) constructor.
* constructed using the @c basic_stream_socket(io_context&) constructor.
*/
template <typename Protocol1, typename StreamSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
@ -325,7 +325,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The send operation may not transmit all of the data to the peer.
* Consider using the @ref async_write function if you need to ensure that all
@ -377,7 +377,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The send operation may not transmit all of the data to the peer.
* Consider using the @ref async_write function if you need to ensure that all
@ -533,7 +533,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The receive operation may not receive all of the requested number of
* bytes. Consider using the @ref async_read function if you need to ensure
@ -586,7 +586,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The receive operation may not receive all of the requested number of
* bytes. Consider using the @ref async_read function if you need to ensure
@ -698,7 +698,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The write operation may not transmit all of the data to the peer.
* Consider using the @ref async_write function if you need to ensure that all
@ -810,7 +810,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The read operation may not read all of the requested number of bytes.
* Consider using the @ref async_read function if you need to ensure that the

View File

@ -51,7 +51,7 @@ namespace asio {
* Performing a blocking wait (C++11):
* @code
* // Construct a timer without setting an expiry time.
* asio::steady_timer timer(io_service);
* asio::steady_timer timer(io_context);
*
* // Set an expiry time relative to now.
* timer.expires_after(std::chrono::seconds(5));
@ -74,7 +74,7 @@ namespace asio {
* ...
*
* // Construct a timer with an absolute expiry time.
* asio::steady_timer timer(io_service,
* asio::steady_timer timer(io_context,
* std::chrono::steady_clock::now() + std::chrono::seconds(60));
*
* // Start an asynchronous wait.
@ -145,11 +145,11 @@ public:
* expires_at() or expires_after() functions must be called to set an expiry
* time before the timer can be waited on.
*
* @param io_service The io_service object that the timer will use to dispatch
* @param io_context The io_context object that the timer will use to dispatch
* handlers for any asynchronous operations performed on the timer.
*/
explicit basic_waitable_timer(asio::io_service& io_service)
: basic_io_object<WaitableTimerService>(io_service)
explicit basic_waitable_timer(asio::io_context& io_context)
: basic_io_object<WaitableTimerService>(io_context)
{
}
@ -157,15 +157,15 @@ public:
/**
* This constructor creates a timer and sets the expiry time.
*
* @param io_service The io_service object that the timer will use to dispatch
* @param io_context The io_context object that the timer will use to dispatch
* handlers for any asynchronous operations performed on the timer.
*
* @param expiry_time The expiry time to be used for the timer, expressed
* as an absolute time.
*/
basic_waitable_timer(asio::io_service& io_service,
basic_waitable_timer(asio::io_context& io_context,
const time_point& expiry_time)
: basic_io_object<WaitableTimerService>(io_service)
: basic_io_object<WaitableTimerService>(io_context)
{
asio::error_code ec;
this->get_service().expires_at(this->get_implementation(), expiry_time, ec);
@ -176,15 +176,15 @@ public:
/**
* This constructor creates a timer and sets the expiry time.
*
* @param io_service The io_service object that the timer will use to dispatch
* @param io_context The io_context object that the timer will use to dispatch
* handlers for any asynchronous operations performed on the timer.
*
* @param expiry_time The expiry time to be used for the timer, relative to
* now.
*/
basic_waitable_timer(asio::io_service& io_service,
basic_waitable_timer(asio::io_context& io_context,
const duration& expiry_time)
: basic_io_object<WaitableTimerService>(io_service)
: basic_io_object<WaitableTimerService>(io_context)
{
asio::error_code ec;
this->get_service().expires_after(
@ -201,7 +201,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_waitable_timer(io_service&) constructor.
* constructed using the @c basic_waitable_timer(io_context&) constructor.
*/
basic_waitable_timer(basic_waitable_timer&& other)
: basic_io_object<WaitableTimerService>(
@ -217,7 +217,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_waitable_timer(io_service&) constructor.
* constructed using the @c basic_waitable_timer(io_context&) constructor.
*/
basic_waitable_timer& operator=(basic_waitable_timer&& other)
{
@ -611,7 +611,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename WaitHandler>
ASIO_INITFN_RESULT_TYPE(WaitHandler,

View File

@ -26,7 +26,7 @@
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/type_traits.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -96,11 +96,20 @@ public:
return next_layer_.lowest_layer();
}
/// Get the io_service associated with the object.
asio::io_service& get_io_service()
/// 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
/// object.
asio::io_context& get_io_service()
{
return next_layer_.get_io_service();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Close the stream.
void close()

View File

@ -23,7 +23,7 @@
#include "asio/buffered_stream_fwd.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -87,11 +87,20 @@ public:
return stream_impl_.lowest_layer();
}
/// Get the io_service associated with the object.
asio::io_service& get_io_service()
/// 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
/// object.
asio::io_context& get_io_service()
{
return stream_impl_.get_io_service();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Close the stream.
void close()

View File

@ -25,7 +25,7 @@
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/type_traits.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/write.hpp"
#include "asio/detail/push_options.hpp"
@ -96,11 +96,20 @@ public:
return next_layer_.lowest_layer();
}
/// Get the io_service associated with the object.
asio::io_service& get_io_service()
/// 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
/// object.
asio::io_context& get_io_service()
{
return next_layer_.get_io_service();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Close the stream.
void close()

View File

@ -81,9 +81,9 @@ struct is_endpoint_sequence
* Otherwise, contains the error from the last connection attempt.
*
* @par Example
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* asio::connect(s, r.resolve(q)); @endcode
*/
template <typename Protocol, typename SocketService, typename EndpointSequence>
@ -112,9 +112,9 @@ typename Protocol::endpoint connect(basic_socket<Protocol, SocketService>& s,
* default-constructed endpoint.
*
* @par Example
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* asio::error_code ec;
* asio::connect(s, r.resolve(q), ec);
* if (ec)
@ -208,10 +208,10 @@ Iterator connect(basic_socket<Protocol, SocketService>& s,
* Otherwise, contains the error from the last connection attempt.
*
* @par Example
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::resolver::results_type e = r.resolve(q);
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* asio::connect(s, e.begin(), e.end()); @endcode
*/
template <typename Protocol, typename SocketService, typename Iterator>
@ -240,10 +240,10 @@ Iterator connect(basic_socket<Protocol, SocketService>& s,
* endpoint. Otherwise, the end iterator.
*
* @par Example
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::resolver::results_type e = r.resolve(q);
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* asio::error_code ec;
* asio::connect(s, e.begin(), e.end(), ec);
* if (ec)
@ -299,9 +299,9 @@ Iterator connect(basic_socket<Protocol, SocketService>& s,
* }
* }; @endcode
* It would be used with the asio::connect function as follows:
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* tcp::endpoint e = asio::connect(s,
* r.resolve(q), my_connect_condition());
* std::cout << "Connected to: " << e << std::endl; @endcode
@ -358,9 +358,9 @@ typename Protocol::endpoint connect(basic_socket<Protocol, SocketService>& s,
* }
* }; @endcode
* It would be used with the asio::connect function as follows:
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* asio::error_code ec;
* tcp::endpoint e = asio::connect(s,
* r.resolve(q), my_connect_condition(), ec);
@ -511,10 +511,10 @@ Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
* }
* }; @endcode
* It would be used with the asio::connect function as follows:
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::resolver::results_type e = r.resolve(q);
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* tcp::resolver::results_type::iterator i = asio::connect(
* s, e.begin(), e.end(), my_connect_condition());
* std::cout << "Connected to: " << i->endpoint() << std::endl; @endcode
@ -571,10 +571,10 @@ Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
* }
* }; @endcode
* It would be used with the asio::connect function as follows:
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::resolver::results_type e = r.resolve(q);
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* asio::error_code ec;
* tcp::resolver::results_type::iterator i = asio::connect(
* s, e.begin(), e.end(), my_connect_condition());
@ -632,12 +632,12 @@ Iterator connect(basic_socket<Protocol, SocketService>& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::socket s(io_service);
* tcp::socket s(io_context);
*
* // ...
*
@ -704,7 +704,7 @@ async_connect(basic_socket<Protocol, SocketService>& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note This overload assumes that a default constructed object of type @c
* Iterator represents the end of the sequence. This is a valid assumption for
@ -750,11 +750,11 @@ async_connect(basic_socket<Protocol, SocketService>& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code std::vector<tcp::endpoint> endpoints = ...;
* tcp::socket s(io_service);
* tcp::socket s(io_context);
* asio::async_connect(s,
* endpoints.begin(), endpoints.end(),
* connect_handler);
@ -816,7 +816,7 @@ async_connect(basic_socket<Protocol, SocketService>& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* The following connect condition function object can be used to output
@ -833,9 +833,9 @@ async_connect(basic_socket<Protocol, SocketService>& s,
* }
* }; @endcode
* It would be used with the asio::connect function as follows:
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::socket s(io_service);
* tcp::socket s(io_context);
*
* // ...
*
@ -922,7 +922,7 @@ async_connect(basic_socket<Protocol, SocketService>& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note This overload assumes that a default constructed object of type @c
* Iterator represents the end of the sequence. This is a valid assumption for
@ -980,7 +980,7 @@ async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* The following connect condition function object can be used to output
@ -997,9 +997,9 @@ async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
* }
* }; @endcode
* It would be used with the asio::connect function as follows:
* @code tcp::resolver r(io_service);
* @code tcp::resolver r(io_context);
* tcp::resolver::query q("host", "service");
* tcp::socket s(io_service);
* tcp::socket s(io_context);
*
* // ...
*

View File

@ -205,7 +205,7 @@ class coroutine_ref;
* {
* do
* {
* socket_.reset(new tcp::socket(io_service_));
* socket_.reset(new tcp::socket(io_context_));
* yield acceptor->async_accept(*socket_, *this);
* fork server(*this)();
* } while (is_parent());
@ -227,7 +227,7 @@ class coroutine_ref;
* Note that @c fork doesn't do the actual forking by itself. It is the
* application's responsibility to create a clone of the coroutine and call it.
* The clone can be called immediately, as above, or scheduled for delayed
* execution using something like io_service::post().
* execution using something like io_context::post().
*
* @par Alternate macro names
*

View File

@ -20,7 +20,7 @@
#include "asio/async_result.hpp"
#include "asio/detail/type_traits.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#if defined(ASIO_WINDOWS_RUNTIME)
# include "asio/detail/null_socket_service.hpp"
@ -38,7 +38,7 @@ namespace asio {
template <typename Protocol>
class datagram_socket_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<datagram_socket_service<Protocol> >
#endif
@ -46,7 +46,7 @@ class datagram_socket_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
/// The protocol type.
@ -80,11 +80,11 @@ public:
typedef typename service_impl_type::native_handle_type native_handle_type;
#endif
/// Construct a new datagram socket service for the specified io_service.
explicit datagram_socket_service(asio::io_service& io_service)
/// Construct a new datagram socket service for the specified io_context.
explicit datagram_socket_service(asio::io_context& io_context)
: asio::detail::service_base<
datagram_socket_service<Protocol> >(io_service),
service_impl_(io_service)
datagram_socket_service<Protocol> >(io_context),
service_impl_(io_context)
{
}

View File

@ -23,7 +23,7 @@
#include <cstddef>
#include "asio/async_result.hpp"
#include "asio/detail/deadline_timer_service.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/time_traits.hpp"
#include "asio/detail/timer_queue_ptime.hpp"
@ -36,7 +36,7 @@ template <typename TimeType,
typename TimeTraits = asio::time_traits<TimeType> >
class deadline_timer_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<
deadline_timer_service<TimeType, TimeTraits> >
@ -45,7 +45,7 @@ class deadline_timer_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
/// The time traits type.
@ -69,11 +69,11 @@ public:
typedef typename service_impl_type::implementation_type implementation_type;
#endif
/// Construct a new timer service for the specified io_service.
explicit deadline_timer_service(asio::io_service& io_service)
/// Construct a new timer service for the specified io_context.
explicit deadline_timer_service(asio::io_context& io_context)
: asio::detail::service_base<
deadline_timer_service<TimeType, TimeTraits> >(io_service),
service_impl_(io_service)
deadline_timer_service<TimeType, TimeTraits> >(io_context),
service_impl_(io_context)
{
}

View File

@ -25,7 +25,7 @@ namespace asio {
namespace detail {
// Helper class to determine whether or not the current thread is inside an
// invocation of io_service::run() for a specified io_service object.
// invocation of io_context::run() for a specified io_context object.
template <typename Key, typename Value = unsigned char>
class call_stack
{

View File

@ -18,7 +18,7 @@
#include "asio/detail/config.hpp"
#include <cstddef>
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/bind_handler.hpp"
#include "asio/detail/fenced_block.hpp"
#include "asio/detail/memory.hpp"
@ -61,8 +61,8 @@ public:
};
// Constructor.
deadline_timer_service(asio::io_service& io_service)
: scheduler_(asio::use_service<timer_scheduler>(io_service))
deadline_timer_service(asio::io_context& io_context)
: scheduler_(asio::use_service<timer_scheduler>(io_context))
{
scheduler_.init_task();
scheduler_.add_timer_queue(timer_queue_);

View File

@ -67,7 +67,7 @@ void dev_poll_reactor::shutdown_service()
scheduler_.abandon_operations(ops);
}
void dev_poll_reactor::fork_service(asio::io_service::fork_event fork_ev)
void dev_poll_reactor::fork_service(asio::io_context::fork_event fork_ev)
{
if (fork_ev == asio::execution_context::fork_child)
{

View File

@ -30,8 +30,8 @@ namespace asio {
namespace detail {
reactive_descriptor_service::reactive_descriptor_service(
asio::io_service& io_service)
: reactor_(asio::use_service<reactor>(io_service))
asio::io_context& io_context)
: reactor_(asio::use_service<reactor>(io_context))
{
reactor_.init_task();
}

View File

@ -30,8 +30,8 @@ namespace asio {
namespace detail {
reactive_serial_port_service::reactive_serial_port_service(
asio::io_service& io_service)
: descriptor_service_(io_service)
asio::io_context& io_context)
: descriptor_service_(io_context)
{
}

View File

@ -28,9 +28,9 @@ namespace asio {
namespace detail {
reactive_socket_service_base::reactive_socket_service_base(
asio::io_service& io_service)
: io_service_(io_service),
reactor_(use_service<reactor>(io_service))
asio::io_context& io_context)
: io_context_(io_context),
reactor_(use_service<reactor>(io_context))
{
reactor_.init_task();
}

View File

@ -23,23 +23,23 @@
namespace asio {
namespace detail {
class resolver_service_base::work_io_service_runner
class resolver_service_base::work_io_context_runner
{
public:
work_io_service_runner(asio::io_service& io_service)
: io_service_(io_service) {}
void operator()() { io_service_.run(); }
work_io_context_runner(asio::io_context& io_context)
: io_context_(io_context) {}
void operator()() { io_context_.run(); }
private:
asio::io_service& io_service_;
asio::io_context& io_context_;
};
resolver_service_base::resolver_service_base(
asio::io_service& io_service)
: io_service_impl_(asio::use_service<io_service_impl>(io_service)),
work_io_service_(new asio::io_service),
work_io_service_impl_(asio::use_service<
io_service_impl>(*work_io_service_)),
work_(new asio::io_service::work(*work_io_service_)),
asio::io_context& io_context)
: io_context_impl_(asio::use_service<io_context_impl>(io_context)),
work_io_context_(new asio::io_context),
work_io_context_impl_(asio::use_service<
io_context_impl>(*work_io_context_)),
work_(new asio::io_context::work(*work_io_context_)),
work_thread_(0)
{
}
@ -52,33 +52,33 @@ resolver_service_base::~resolver_service_base()
void resolver_service_base::shutdown_service()
{
work_.reset();
if (work_io_service_.get())
if (work_io_context_.get())
{
work_io_service_->stop();
work_io_context_->stop();
if (work_thread_.get())
{
work_thread_->join();
work_thread_.reset();
}
work_io_service_.reset();
work_io_context_.reset();
}
}
void resolver_service_base::fork_service(
asio::io_service::fork_event fork_ev)
asio::io_context::fork_event fork_ev)
{
if (work_thread_.get())
{
if (fork_ev == asio::io_service::fork_prepare)
if (fork_ev == asio::io_context::fork_prepare)
{
work_io_service_->stop();
work_io_context_->stop();
work_thread_->join();
}
else
{
work_io_service_->restart();
work_io_context_->restart();
work_thread_.reset(new asio::detail::thread(
work_io_service_runner(*work_io_service_)));
work_io_context_runner(*work_io_context_)));
}
}
}
@ -92,7 +92,7 @@ void resolver_service_base::construct(
void resolver_service_base::destroy(
resolver_service_base::implementation_type& impl)
{
ASIO_HANDLER_OPERATION((io_service_impl_.context(),
ASIO_HANDLER_OPERATION((io_context_impl_.context(),
"resolver", &impl, 0, "cancel"));
impl.reset();
@ -101,7 +101,7 @@ void resolver_service_base::destroy(
void resolver_service_base::cancel(
resolver_service_base::implementation_type& impl)
{
ASIO_HANDLER_OPERATION((io_service_impl_.context(),
ASIO_HANDLER_OPERATION((io_context_impl_.context(),
"resolver", &impl, 0, "cancel"));
impl.reset(static_cast<void*>(0), socket_ops::noop_deleter());
@ -110,8 +110,8 @@ void resolver_service_base::cancel(
void resolver_service_base::start_resolve_op(operation* op)
{
start_work_thread();
io_service_impl_.work_started();
work_io_service_impl_.post_immediate_completion(op, false);
io_context_impl_.work_started();
work_io_context_impl_.post_immediate_completion(op, false);
}
void resolver_service_base::start_work_thread()
@ -120,7 +120,7 @@ void resolver_service_base::start_work_thread()
if (!work_thread_.get())
{
work_thread_.reset(new asio::detail::thread(
work_io_service_runner(*work_io_service_)));
work_io_context_runner(*work_io_context_)));
}
}

View File

@ -30,11 +30,11 @@ Service& service_registry::use_service()
}
template <typename Service>
Service& service_registry::use_service(io_service& owner)
Service& service_registry::use_service(io_context& owner)
{
execution_context::service::key key;
init_key(key, Service::id);
factory_type factory = &service_registry::create<Service, io_service>;
factory_type factory = &service_registry::create<Service, io_context>;
return *static_cast<Service*>(do_use_service(key, factory, &owner));
}

View File

@ -117,12 +117,12 @@ public:
// && !defined(__CYGWIN__)
signal_set_service::signal_set_service(
asio::io_service& io_service)
: io_service_(asio::use_service<io_service_impl>(io_service)),
asio::io_context& io_context)
: io_context_(asio::use_service<io_context_impl>(io_context)),
#if !defined(ASIO_WINDOWS) \
&& !defined(ASIO_WINDOWS_RUNTIME) \
&& !defined(__CYGWIN__)
reactor_(asio::use_service<reactor>(io_service)),
reactor_(asio::use_service<reactor>(io_context)),
#endif // !defined(ASIO_WINDOWS)
// && !defined(ASIO_WINDOWS_RUNTIME)
// && !defined(__CYGWIN__)
@ -166,11 +166,11 @@ void signal_set_service::shutdown_service()
}
}
io_service_.abandon_operations(ops);
io_context_.abandon_operations(ops);
}
void signal_set_service::fork_service(
asio::io_service::fork_event fork_ev)
asio::io_context::fork_event fork_ev)
{
#if !defined(ASIO_WINDOWS) \
&& !defined(ASIO_WINDOWS_RUNTIME) \
@ -180,7 +180,7 @@ void signal_set_service::fork_service(
switch (fork_ev)
{
case asio::io_service::fork_prepare:
case asio::io_context::fork_prepare:
{
int read_descriptor = state->read_descriptor_;
state->fork_prepared_ = true;
@ -188,7 +188,7 @@ void signal_set_service::fork_service(
reactor_.deregister_internal_descriptor(read_descriptor, reactor_data_);
}
break;
case asio::io_service::fork_parent:
case asio::io_context::fork_parent:
if (state->fork_prepared_)
{
int read_descriptor = state->read_descriptor_;
@ -198,7 +198,7 @@ void signal_set_service::fork_service(
read_descriptor, reactor_data_, new pipe_read_op);
}
break;
case asio::io_service::fork_child:
case asio::io_context::fork_child:
if (state->fork_prepared_)
{
asio::detail::signal_blocker blocker;
@ -437,7 +437,7 @@ asio::error_code signal_set_service::cancel(
signal_set_service::implementation_type& impl,
asio::error_code& ec)
{
ASIO_HANDLER_OPERATION((io_service_.context(),
ASIO_HANDLER_OPERATION((io_context_.context(),
"signal_set", &impl, 0, "cancel"));
op_queue<operation> ops;
@ -453,7 +453,7 @@ asio::error_code signal_set_service::cancel(
}
}
io_service_.post_deferred_completions(ops);
io_context_.post_deferred_completions(ops);
ec = asio::error_code();
return ec;
@ -489,7 +489,7 @@ void signal_set_service::deliver_signal(int signal_number)
reg = reg->next_in_table_;
}
service->io_service_.post_deferred_completions(ops);
service->io_context_.post_deferred_completions(ops);
service = service->next_;
}
@ -618,7 +618,7 @@ void signal_set_service::close_descriptors()
void signal_set_service::start_wait_op(
signal_set_service::implementation_type& impl, signal_op* op)
{
io_service_.work_started();
io_context_.work_started();
signal_state* state = get_signal_state();
static_mutex::scoped_lock lock(state->mutex_);
@ -630,7 +630,7 @@ void signal_set_service::start_wait_op(
{
--reg->undelivered_;
op->signal_number_ = reg->signal_number_;
io_service_.post_deferred_completion(op);
io_context_.post_deferred_completion(op);
return;
}

View File

@ -35,7 +35,7 @@ inline strand_service::strand_impl::strand_impl()
struct strand_service::on_dispatch_exit
{
io_service_impl* io_service_;
io_context_impl* io_context_;
strand_impl* impl_;
~on_dispatch_exit()
@ -46,7 +46,7 @@ struct strand_service::on_dispatch_exit
impl_->mutex_.unlock();
if (more_handlers)
io_service_->post_immediate_completion(impl_, false);
io_context_->post_immediate_completion(impl_, false);
}
};
@ -81,15 +81,15 @@ void strand_service::dispatch(strand_service::implementation_type& impl,
call_stack<strand_impl>::context ctx(impl);
// Ensure the next handler, if any, is scheduled on block exit.
on_dispatch_exit on_exit = { &io_service_, impl };
on_dispatch_exit on_exit = { &io_context_, impl };
(void)on_exit;
completion_handler<Handler>::do_complete(
&io_service_, o, asio::error_code(), 0);
&io_context_, o, asio::error_code(), 0);
}
}
// Request the io_service to invoke the given handler and return immediately.
// Request the io_context to invoke the given handler and return immediately.
template <typename Handler>
void strand_service::post(strand_service::implementation_type& impl,
Handler& handler)

View File

@ -26,7 +26,7 @@ namespace detail {
struct strand_service::on_do_complete_exit
{
io_service_impl* owner_;
io_context_impl* owner_;
strand_impl* impl_;
~on_do_complete_exit()
@ -41,9 +41,9 @@ struct strand_service::on_do_complete_exit
}
};
strand_service::strand_service(asio::io_service& io_service)
: asio::detail::service_base<strand_service>(io_service),
io_service_(asio::use_service<io_service_impl>(io_service)),
strand_service::strand_service(asio::io_context& io_context)
: asio::detail::service_base<strand_service>(io_context),
io_context_(asio::use_service<io_context_impl>(io_context)),
mutex_(),
salt_(0)
{
@ -92,9 +92,9 @@ bool strand_service::running_in_this_thread(
bool strand_service::do_dispatch(implementation_type& impl, operation* op)
{
// If we are running inside the io_service, and no other handler already
// If we are running inside the io_context, and no other handler already
// holds the strand lock, then the handler can run immediately.
bool can_dispatch = io_service_.can_dispatch();
bool can_dispatch = io_context_.can_dispatch();
impl->mutex_.lock();
if (can_dispatch && !impl->locked_)
{
@ -117,7 +117,7 @@ bool strand_service::do_dispatch(implementation_type& impl, operation* op)
impl->locked_ = true;
impl->mutex_.unlock();
impl->ready_queue_.push(op);
io_service_.post_immediate_completion(impl, false);
io_context_.post_immediate_completion(impl, false);
}
return false;
@ -140,7 +140,7 @@ void strand_service::do_post(implementation_type& impl,
impl->locked_ = true;
impl->mutex_.unlock();
impl->ready_queue_.push(op);
io_service_.post_immediate_completion(impl, is_continuation);
io_context_.post_immediate_completion(impl, is_continuation);
}
}
@ -156,7 +156,7 @@ void strand_service::do_complete(void* owner, operation* base,
// Ensure the next handler, if any, is scheduled on block exit.
on_do_complete_exit on_exit;
on_exit.owner_ = static_cast<io_service_impl*>(owner);
on_exit.owner_ = static_cast<io_context_impl*>(owner);
on_exit.impl_ = impl;
// Run all ready handlers. No lock is required since the ready queue is

View File

@ -66,8 +66,8 @@ public:
};
win_iocp_handle_service::win_iocp_handle_service(
asio::io_service& io_service)
: iocp_service_(asio::use_service<win_iocp_io_service>(io_service)),
asio::io_context& io_context)
: iocp_service_(asio::use_service<win_iocp_io_context>(io_context)),
mutex_(),
impl_list_(0)
{

View File

@ -1,5 +1,5 @@
//
// detail/impl/win_iocp_io_service.hpp
// detail/impl/win_iocp_io_context.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
@ -8,8 +8,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP
#define ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP
#ifndef ASIO_DETAIL_IMPL_WIN_IOCP_IO_CONTEXT_HPP
#define ASIO_DETAIL_IMPL_WIN_IOCP_IO_CONTEXT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
@ -31,21 +31,21 @@ namespace asio {
namespace detail {
template <typename Time_Traits>
void win_iocp_io_service::add_timer_queue(
void win_iocp_io_context::add_timer_queue(
timer_queue<Time_Traits>& queue)
{
do_add_timer_queue(queue);
}
template <typename Time_Traits>
void win_iocp_io_service::remove_timer_queue(
void win_iocp_io_context::remove_timer_queue(
timer_queue<Time_Traits>& queue)
{
do_remove_timer_queue(queue);
}
template <typename Time_Traits>
void win_iocp_io_service::schedule_timer(timer_queue<Time_Traits>& queue,
void win_iocp_io_context::schedule_timer(timer_queue<Time_Traits>& queue,
const typename Time_Traits::time_type& time,
typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
{
@ -65,7 +65,7 @@ void win_iocp_io_service::schedule_timer(timer_queue<Time_Traits>& queue,
}
template <typename Time_Traits>
std::size_t win_iocp_io_service::cancel_timer(timer_queue<Time_Traits>& queue,
std::size_t win_iocp_io_context::cancel_timer(timer_queue<Time_Traits>& queue,
typename timer_queue<Time_Traits>::per_timer_data& timer,
std::size_t max_cancelled)
{
@ -81,7 +81,7 @@ std::size_t win_iocp_io_service::cancel_timer(timer_queue<Time_Traits>& queue,
}
template <typename Time_Traits>
void win_iocp_io_service::move_timer(timer_queue<Time_Traits>& queue,
void win_iocp_io_context::move_timer(timer_queue<Time_Traits>& queue,
typename timer_queue<Time_Traits>::per_timer_data& to,
typename timer_queue<Time_Traits>::per_timer_data& from)
{
@ -100,4 +100,4 @@ void win_iocp_io_service::move_timer(timer_queue<Time_Traits>& queue,
#endif // defined(ASIO_HAS_IOCP)
#endif // ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP
#endif // ASIO_DETAIL_IMPL_WIN_IOCP_IO_CONTEXT_HPP

View File

@ -1,5 +1,5 @@
//
// detail/impl/win_iocp_io_service.ipp
// detail/impl/win_iocp_io_context.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
@ -8,8 +8,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_IPP
#define ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_IPP
#ifndef ASIO_DETAIL_IMPL_WIN_IOCP_IO_CONTEXT_IPP
#define ASIO_DETAIL_IMPL_WIN_IOCP_IO_CONTEXT_IPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
@ -25,45 +25,45 @@
#include "asio/detail/handler_invoke_helpers.hpp"
#include "asio/detail/limits.hpp"
#include "asio/detail/throw_error.hpp"
#include "asio/detail/win_iocp_io_service.hpp"
#include "asio/detail/win_iocp_io_context.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
namespace detail {
struct win_iocp_io_service::work_finished_on_block_exit
struct win_iocp_io_context::work_finished_on_block_exit
{
~work_finished_on_block_exit()
{
io_service_->work_finished();
io_context_->work_finished();
}
win_iocp_io_service* io_service_;
win_iocp_io_context* io_context_;
};
struct win_iocp_io_service::timer_thread_function
struct win_iocp_io_context::timer_thread_function
{
void operator()()
{
while (::InterlockedExchangeAdd(&io_service_->shutdown_, 0) == 0)
while (::InterlockedExchangeAdd(&io_context_->shutdown_, 0) == 0)
{
if (::WaitForSingleObject(io_service_->waitable_timer_.handle,
if (::WaitForSingleObject(io_context_->waitable_timer_.handle,
INFINITE) == WAIT_OBJECT_0)
{
::InterlockedExchange(&io_service_->dispatch_required_, 1);
::PostQueuedCompletionStatus(io_service_->iocp_.handle,
::InterlockedExchange(&io_context_->dispatch_required_, 1);
::PostQueuedCompletionStatus(io_context_->iocp_.handle,
0, wake_for_dispatch, 0);
}
}
}
win_iocp_io_service* io_service_;
win_iocp_io_context* io_context_;
};
win_iocp_io_service::win_iocp_io_service(
win_iocp_io_context::win_iocp_io_context(
asio::execution_context& ctx, size_t concurrency_hint)
: execution_context_service_base<win_iocp_io_service>(ctx),
: execution_context_service_base<win_iocp_io_context>(ctx),
iocp_(),
outstanding_work_(0),
stopped_(0),
@ -86,7 +86,7 @@ win_iocp_io_service::win_iocp_io_service(
}
}
void win_iocp_io_service::shutdown_service()
void win_iocp_io_context::shutdown_service()
{
::InterlockedExchange(&shutdown_, 1);
@ -130,7 +130,7 @@ void win_iocp_io_service::shutdown_service()
timer_thread_->join();
}
asio::error_code win_iocp_io_service::register_handle(
asio::error_code win_iocp_io_context::register_handle(
HANDLE handle, asio::error_code& ec)
{
if (::CreateIoCompletionPort(handle, iocp_.handle, 0, 0) == 0)
@ -146,7 +146,7 @@ asio::error_code win_iocp_io_service::register_handle(
return ec;
}
size_t win_iocp_io_service::run(asio::error_code& ec)
size_t win_iocp_io_context::run(asio::error_code& ec)
{
if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0)
{
@ -165,7 +165,7 @@ size_t win_iocp_io_service::run(asio::error_code& ec)
return n;
}
size_t win_iocp_io_service::run_one(asio::error_code& ec)
size_t win_iocp_io_context::run_one(asio::error_code& ec)
{
if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0)
{
@ -180,7 +180,7 @@ size_t win_iocp_io_service::run_one(asio::error_code& ec)
return do_one(true, ec);
}
size_t win_iocp_io_service::poll(asio::error_code& ec)
size_t win_iocp_io_context::poll(asio::error_code& ec)
{
if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0)
{
@ -199,7 +199,7 @@ size_t win_iocp_io_service::poll(asio::error_code& ec)
return n;
}
size_t win_iocp_io_service::poll_one(asio::error_code& ec)
size_t win_iocp_io_context::poll_one(asio::error_code& ec)
{
if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0)
{
@ -214,7 +214,7 @@ size_t win_iocp_io_service::poll_one(asio::error_code& ec)
return do_one(false, ec);
}
void win_iocp_io_service::stop()
void win_iocp_io_context::stop()
{
if (::InterlockedExchange(&stopped_, 1) == 0)
{
@ -231,7 +231,7 @@ void win_iocp_io_service::stop()
}
}
void win_iocp_io_service::post_deferred_completion(win_iocp_operation* op)
void win_iocp_io_context::post_deferred_completion(win_iocp_operation* op)
{
// Flag the operation as ready.
op->ready_ = 1;
@ -246,7 +246,7 @@ void win_iocp_io_service::post_deferred_completion(win_iocp_operation* op)
}
}
void win_iocp_io_service::post_deferred_completions(
void win_iocp_io_context::post_deferred_completions(
op_queue<win_iocp_operation>& ops)
{
while (win_iocp_operation* op = ops.front())
@ -268,7 +268,7 @@ void win_iocp_io_service::post_deferred_completions(
}
}
void win_iocp_io_service::abandon_operations(
void win_iocp_io_context::abandon_operations(
op_queue<win_iocp_operation>& ops)
{
while (win_iocp_operation* op = ops.front())
@ -279,7 +279,7 @@ void win_iocp_io_service::abandon_operations(
}
}
void win_iocp_io_service::on_pending(win_iocp_operation* op)
void win_iocp_io_context::on_pending(win_iocp_operation* op)
{
if (::InterlockedCompareExchange(&op->ready_, 1, 0) == 1)
{
@ -295,7 +295,7 @@ void win_iocp_io_service::on_pending(win_iocp_operation* op)
}
}
void win_iocp_io_service::on_completion(win_iocp_operation* op,
void win_iocp_io_context::on_completion(win_iocp_operation* op,
DWORD last_error, DWORD bytes_transferred)
{
// Flag that the operation is ready for invocation.
@ -318,7 +318,7 @@ void win_iocp_io_service::on_completion(win_iocp_operation* op,
}
}
void win_iocp_io_service::on_completion(win_iocp_operation* op,
void win_iocp_io_context::on_completion(win_iocp_operation* op,
const asio::error_code& ec, DWORD bytes_transferred)
{
// Flag that the operation is ready for invocation.
@ -340,7 +340,7 @@ void win_iocp_io_service::on_completion(win_iocp_operation* op,
}
}
size_t win_iocp_io_service::do_one(bool block, asio::error_code& ec)
size_t win_iocp_io_context::do_one(bool block, asio::error_code& ec)
{
for (;;)
{
@ -454,7 +454,7 @@ size_t win_iocp_io_service::do_one(bool block, asio::error_code& ec)
}
}
DWORD win_iocp_io_service::get_gqcs_timeout()
DWORD win_iocp_io_context::get_gqcs_timeout()
{
OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(osvi));
@ -470,7 +470,7 @@ DWORD win_iocp_io_service::get_gqcs_timeout()
return default_gqcs_timeout;
}
void win_iocp_io_service::do_add_timer_queue(timer_queue_base& queue)
void win_iocp_io_context::do_add_timer_queue(timer_queue_base& queue)
{
mutex::scoped_lock lock(dispatch_mutex_);
@ -501,14 +501,14 @@ void win_iocp_io_service::do_add_timer_queue(timer_queue_base& queue)
}
}
void win_iocp_io_service::do_remove_timer_queue(timer_queue_base& queue)
void win_iocp_io_context::do_remove_timer_queue(timer_queue_base& queue)
{
mutex::scoped_lock lock(dispatch_mutex_);
timer_queues_.erase(&queue);
}
void win_iocp_io_service::update_timeout()
void win_iocp_io_context::update_timeout()
{
if (timer_thread_.get())
{
@ -534,4 +534,4 @@ void win_iocp_io_service::update_timeout()
#endif // defined(ASIO_HAS_IOCP)
#endif // ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_IPP
#endif // ASIO_DETAIL_IMPL_WIN_IOCP_IO_CONTEXT_IPP

View File

@ -29,8 +29,8 @@ namespace asio {
namespace detail {
win_iocp_serial_port_service::win_iocp_serial_port_service(
asio::io_service& io_service)
: handle_service_(io_service)
asio::io_context& io_context)
: handle_service_(io_context)
{
}

View File

@ -27,9 +27,9 @@ namespace asio {
namespace detail {
win_iocp_socket_service_base::win_iocp_socket_service_base(
asio::io_service& io_service)
: io_service_(io_service),
iocp_service_(use_service<win_iocp_io_service>(io_service)),
asio::io_context& io_context)
: io_context_(io_context),
iocp_service_(use_service<win_iocp_io_context>(io_context)),
reactor_(0),
connect_ex_(0),
mutex_(),
@ -663,7 +663,7 @@ select_reactor& win_iocp_socket_service_base::get_reactor()
reinterpret_cast<void**>(&reactor_), 0, 0));
if (!r)
{
r = &(use_service<select_reactor>(io_service_));
r = &(use_service<select_reactor>(io_context_));
interlocked_exchange_pointer(reinterpret_cast<void**>(&reactor_), r);
}
return *r;

View File

@ -28,8 +28,8 @@ namespace asio {
namespace detail {
win_object_handle_service::win_object_handle_service(
asio::io_service& io_service)
: io_service_(asio::use_service<io_service_impl>(io_service)),
asio::io_context& io_context)
: io_context_(asio::use_service<io_context_impl>(io_context)),
mutex_(),
impl_list_(0),
shutdown_(false)
@ -51,7 +51,7 @@ void win_object_handle_service::shutdown_service()
lock.unlock();
io_service_.abandon_operations(ops);
io_context_.abandon_operations(ops);
}
void win_object_handle_service::construct(
@ -177,7 +177,7 @@ void win_object_handle_service::destroy(
if (is_open(impl))
{
ASIO_HANDLER_OPERATION((io_service_.context(), "object_handle",
ASIO_HANDLER_OPERATION((io_context_.context(), "object_handle",
&impl, reinterpret_cast<uintmax_t>(impl.wait_handle_), "close"));
HANDLE wait_handle = impl.wait_handle_;
@ -202,7 +202,7 @@ void win_object_handle_service::destroy(
::CloseHandle(impl.handle_);
impl.handle_ = INVALID_HANDLE_VALUE;
io_service_.post_deferred_completions(ops);
io_context_.post_deferred_completions(ops);
}
}
@ -227,7 +227,7 @@ asio::error_code win_object_handle_service::close(
{
if (is_open(impl))
{
ASIO_HANDLER_OPERATION((io_service_.context(), "object_handle",
ASIO_HANDLER_OPERATION((io_context_.context(), "object_handle",
&impl, reinterpret_cast<uintmax_t>(impl.wait_handle_), "close"));
mutex::scoped_lock lock(mutex_);
@ -263,7 +263,7 @@ asio::error_code win_object_handle_service::close(
asio::error::get_system_category());
}
io_service_.post_deferred_completions(completed_ops);
io_context_.post_deferred_completions(completed_ops);
}
else
{
@ -279,7 +279,7 @@ asio::error_code win_object_handle_service::cancel(
{
if (is_open(impl))
{
ASIO_HANDLER_OPERATION((io_service_.context(), "object_handle",
ASIO_HANDLER_OPERATION((io_context_.context(), "object_handle",
&impl, reinterpret_cast<uintmax_t>(impl.wait_handle_), "cancel"));
mutex::scoped_lock lock(mutex_);
@ -305,7 +305,7 @@ asio::error_code win_object_handle_service::cancel(
ec = asio::error_code();
io_service_.post_deferred_completions(completed_ops);
io_context_.post_deferred_completions(completed_ops);
}
else
{
@ -339,7 +339,7 @@ void win_object_handle_service::wait(
void win_object_handle_service::start_wait_op(
win_object_handle_service::implementation_type& impl, wait_op* op)
{
io_service_.work_started();
io_context_.work_started();
if (is_open(impl))
{
@ -357,13 +357,13 @@ void win_object_handle_service::start_wait_op(
else
{
lock.unlock();
io_service_.post_deferred_completion(op);
io_context_.post_deferred_completion(op);
}
}
else
{
op->ec_ = asio::error::bad_descriptor;
io_service_.post_deferred_completion(op);
io_context_.post_deferred_completion(op);
}
}
@ -390,7 +390,7 @@ void win_object_handle_service::register_wait_callback(
}
lock.unlock();
io_service_.post_deferred_completions(completed_ops);
io_context_.post_deferred_completions(completed_ops);
}
}
@ -432,9 +432,9 @@ void win_object_handle_service::wait_callback(PVOID param, BOOLEAN)
}
}
io_service_impl& ios = impl->owner_->io_service_;
io_context_impl& ioc = impl->owner_->io_context_;
lock.unlock();
ios.post_deferred_completions(completed_ops);
ioc.post_deferred_completions(completed_ops);
}
}

View File

@ -30,9 +30,9 @@ namespace asio {
namespace detail {
winrt_ssocket_service_base::winrt_ssocket_service_base(
asio::io_service& io_service)
: io_service_(use_service<io_service_impl>(io_service)),
async_manager_(use_service<winrt_async_manager>(io_service)),
asio::io_context& io_context)
: io_context_(use_service<io_context_impl>(io_context)),
async_manager_(use_service<winrt_async_manager>(io_context)),
mutex_(),
impl_list_(0)
{
@ -381,7 +381,7 @@ void winrt_ssocket_service_base::start_connect_op(
if (!is_open(impl))
{
op->ec_ = asio::error::bad_descriptor;
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
@ -410,7 +410,7 @@ void winrt_ssocket_service_base::start_connect_op(
if (op->ec_)
{
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
@ -425,7 +425,7 @@ void winrt_ssocket_service_base::start_connect_op(
{
op->ec_ = asio::error_code(
e->HResult, asio::system_category());
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
}
}
@ -476,14 +476,14 @@ void winrt_ssocket_service_base::start_send_op(
if (flags)
{
op->ec_ = asio::error::operation_not_supported;
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
if (!is_open(impl))
{
op->ec_ = asio::error::bad_descriptor;
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
@ -494,7 +494,7 @@ void winrt_ssocket_service_base::start_send_op(
if (bufs.all_empty())
{
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
@ -505,7 +505,7 @@ void winrt_ssocket_service_base::start_send_op(
{
op->ec_ = asio::error_code(e->HResult,
asio::system_category());
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
}
}
@ -567,14 +567,14 @@ void winrt_ssocket_service_base::start_receive_op(
if (flags)
{
op->ec_ = asio::error::operation_not_supported;
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
if (!is_open(impl))
{
op->ec_ = asio::error::bad_descriptor;
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
@ -585,7 +585,7 @@ void winrt_ssocket_service_base::start_receive_op(
if (bufs.all_empty())
{
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
return;
}
@ -598,7 +598,7 @@ void winrt_ssocket_service_base::start_receive_op(
{
op->ec_ = asio::error_code(e->HResult,
asio::system_category());
io_service_.post_immediate_completion(op, is_continuation);
io_context_.post_immediate_completion(op, is_continuation);
}
}

View File

@ -46,12 +46,12 @@ void winrt_timer_scheduler::schedule_timer(timer_queue<Time_Traits>& queue,
if (shutdown_)
{
io_service_.post_immediate_completion(op, false);
io_context_.post_immediate_completion(op, false);
return;
}
bool earliest = queue.enqueue_timer(time, timer, op);
io_service_.work_started();
io_context_.work_started();
if (earliest)
event_.signal(lock);
}
@ -65,7 +65,7 @@ std::size_t winrt_timer_scheduler::cancel_timer(timer_queue<Time_Traits>& queue,
op_queue<operation> ops;
std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
lock.unlock();
io_service_.post_deferred_completions(ops);
io_context_.post_deferred_completions(ops);
return n;
}

View File

@ -28,9 +28,9 @@ namespace asio {
namespace detail {
winrt_timer_scheduler::winrt_timer_scheduler(
asio::io_service& io_service)
: asio::detail::service_base<winrt_timer_scheduler>(io_service),
io_service_(use_service<io_service_impl>(io_service)),
asio::io_context& io_context)
: asio::detail::service_base<winrt_timer_scheduler>(io_context),
io_context_(use_service<io_context_impl>(io_context)),
mutex_(),
event_(),
timer_queues_(),
@ -64,10 +64,10 @@ void winrt_timer_scheduler::shutdown_service()
op_queue<operation> ops;
timer_queues_.get_all_timers(ops);
io_service_.abandon_operations(ops);
io_context_.abandon_operations(ops);
}
void winrt_timer_scheduler::fork_service(asio::io_service::fork_event)
void winrt_timer_scheduler::fork_service(asio::io_context::fork_event)
{
}
@ -89,7 +89,7 @@ void winrt_timer_scheduler::run_thread()
if (!ops.empty())
{
lock.unlock();
io_service_.post_deferred_completions(ops);
io_context_.post_deferred_completions(ops);
lock.lock();
}
}

View File

@ -21,7 +21,7 @@
#include "asio/buffer.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/bind_handler.hpp"
@ -49,8 +49,8 @@ public:
};
// Constructor.
null_socket_service(asio::io_service& io_service)
: io_service_(io_service)
null_socket_service(asio::io_context& io_context)
: io_context_(io_context)
{
}
@ -267,7 +267,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Start an asynchronous wait until data can be sent without blocking.
@ -277,7 +277,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Receive some data from the peer. Returns the number of bytes received.
@ -305,7 +305,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Wait until data can be received without blocking.
@ -315,7 +315,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Receive some data with associated flags. Returns the number of bytes
@ -347,7 +347,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Wait until data can be received without blocking.
@ -358,7 +358,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Send a datagram to the specified endpoint. Returns the number of bytes
@ -390,7 +390,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Start an asynchronous wait until data can be sent without blocking.
@ -400,7 +400,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Receive a datagram with the endpoint of the sender. Returns the number of
@ -433,7 +433,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Wait until data can be received without blocking.
@ -444,7 +444,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
}
// Accept a new connection.
@ -463,7 +463,7 @@ public:
endpoint_type*, Handler& handler)
{
asio::error_code ec = asio::error::operation_not_supported;
io_service_.post(detail::bind_handler(handler, ec));
io_context_.post(detail::bind_handler(handler, ec));
}
// Connect the socket to the specified endpoint.
@ -480,11 +480,11 @@ public:
const endpoint_type&, Handler& handler)
{
asio::error_code ec = asio::error::operation_not_supported;
io_service_.post(detail::bind_handler(handler, ec));
io_context_.post(detail::bind_handler(handler, ec));
}
private:
asio::io_service& io_service_;
asio::io_context& io_context_;
};
} // namespace detail

View File

@ -22,7 +22,7 @@
&& !defined(__CYGWIN__)
#include "asio/buffer.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/bind_handler.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
#include "asio/detail/descriptor_ops.hpp"
@ -75,7 +75,7 @@ public:
// Constructor.
ASIO_DECL reactive_descriptor_service(
asio::io_service& io_service);
asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();

View File

@ -23,7 +23,7 @@
#include <string>
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/serial_port_base.hpp"
#include "asio/detail/descriptor_ops.hpp"
#include "asio/detail/reactive_descriptor_service.hpp"
@ -44,7 +44,7 @@ public:
typedef reactive_descriptor_service::implementation_type implementation_type;
ASIO_DECL reactive_serial_port_service(
asio::io_service& io_service);
asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();

View File

@ -142,10 +142,10 @@ class reactive_socket_move_accept_op :
public:
ASIO_DEFINE_HANDLER_PTR(reactive_socket_move_accept_op);
reactive_socket_move_accept_op(io_service& ios, socket_type socket,
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(ios),
: Protocol::socket(ioc),
reactive_socket_accept_op_base<typename Protocol::socket, Protocol>(
socket, state, *this, protocol, peer_endpoint,
&reactive_socket_move_accept_op::do_complete),

View File

@ -21,7 +21,7 @@
#include "asio/buffer.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
#include "asio/detail/memory.hpp"
@ -72,8 +72,8 @@ public:
};
// Constructor.
reactive_socket_service(asio::io_service& io_service)
: reactive_socket_service_base(io_service)
reactive_socket_service(asio::io_context& io_context)
: reactive_socket_service_base(io_context)
{
}
@ -392,11 +392,11 @@ public:
#if defined(ASIO_HAS_MOVE)
// Accept a new connection.
typename Protocol::socket accept(implementation_type& impl,
io_service* peer_io_service, endpoint_type* peer_endpoint,
io_context* peer_io_context, endpoint_type* peer_endpoint,
asio::error_code& ec)
{
typename Protocol::socket peer(
peer_io_service ? *peer_io_service : io_service_);
peer_io_context ? *peer_io_context : io_context_);
std::size_t addr_len = peer_endpoint ? peer_endpoint->capacity() : 0;
socket_holder new_socket(socket_ops::sync_accept(impl.socket_,
@ -444,7 +444,7 @@ public:
// the accept's handler is invoked.
template <typename Handler>
void async_accept(implementation_type& impl,
asio::io_service* peer_io_service,
asio::io_context* peer_io_context,
endpoint_type* peer_endpoint, Handler& handler)
{
bool is_continuation =
@ -454,7 +454,7 @@ public:
typedef reactive_socket_move_accept_op<Protocol, Handler> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(peer_io_service ? *peer_io_service : io_service_,
p.p = new (p.v) op(peer_io_context ? *peer_io_context : io_context_,
impl.socket_, impl.state_, impl.protocol_, peer_endpoint, handler);
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",

View File

@ -22,7 +22,7 @@
#include "asio/buffer.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
#include "asio/detail/memory.hpp"
@ -63,7 +63,7 @@ public:
// Constructor.
ASIO_DECL reactive_socket_service_base(
asio::io_service& io_service);
asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();
@ -493,8 +493,8 @@ protected:
reactor_op* op, bool is_continuation,
const socket_addr_type* addr, size_t addrlen);
// The io_service that owns this socket service.
io_service& io_service_;
// The io_context that owns this socket service.
io_context& io_context_;
// The selector that performs event demultiplexing for the service.
reactor& reactor_;

View File

@ -17,7 +17,7 @@
#include "asio/detail/config.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/ip/basic_resolver_results.hpp"
#include "asio/detail/bind_handler.hpp"
#include "asio/detail/fenced_block.hpp"
@ -42,11 +42,11 @@ public:
typedef asio::ip::basic_resolver_results<Protocol> results_type;
resolve_endpoint_op(socket_ops::weak_cancel_token_type cancel_token,
const endpoint_type& endpoint, io_service_impl& ios, Handler& handler)
const endpoint_type& endpoint, io_context_impl& ioc, Handler& handler)
: operation(&resolve_endpoint_op::do_complete),
cancel_token_(cancel_token),
endpoint_(endpoint),
io_service_impl_(ios),
io_context_impl_(ioc),
handler_(ASIO_MOVE_CAST(Handler)(handler))
{
handler_work<Handler>::start(handler_);
@ -61,9 +61,9 @@ public:
ptr p = { asio::detail::addressof(o->handler_), o, o };
handler_work<Handler> w(o->handler_);
if (owner && owner != &o->io_service_impl_)
if (owner && owner != &o->io_context_impl_)
{
// The operation is being run on the worker io_service. Time to perform
// The operation is being run on the worker io_context. Time to perform
// the resolver operation.
// Perform the blocking endpoint resolution operation.
@ -74,13 +74,13 @@ public:
o->endpoint_.protocol().type(), o->ec_);
o->results_ = results_type::create(o->endpoint_, host_name, service_name);
// Pass operation back to main io_service for completion.
o->io_service_impl_.post_deferred_completion(o);
// Pass operation back to main io_context for completion.
o->io_context_impl_.post_deferred_completion(o);
p.v = p.p = 0;
}
else
{
// The operation has been returned to the main io_service. The completion
// The operation has been returned to the main io_context. The completion
// handler is ready to be delivered.
ASIO_HANDLER_COMPLETION((*o));
@ -109,7 +109,7 @@ public:
private:
socket_ops::weak_cancel_token_type cancel_token_;
endpoint_type endpoint_;
io_service_impl& io_service_impl_;
io_context_impl& io_context_impl_;
Handler handler_;
asio::error_code ec_;
results_type results_;

View File

@ -17,7 +17,7 @@
#include "asio/detail/config.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/ip/basic_resolver_query.hpp"
#include "asio/ip/basic_resolver_results.hpp"
#include "asio/detail/bind_handler.hpp"
@ -43,11 +43,11 @@ public:
typedef asio::ip::basic_resolver_results<Protocol> results_type;
resolve_op(socket_ops::weak_cancel_token_type cancel_token,
const query_type& query, io_service_impl& ios, Handler& handler)
const query_type& query, io_context_impl& ioc, Handler& handler)
: operation(&resolve_op::do_complete),
cancel_token_(cancel_token),
query_(query),
io_service_impl_(ios),
io_context_impl_(ioc),
handler_(ASIO_MOVE_CAST(Handler)(handler)),
addrinfo_(0)
{
@ -69,9 +69,9 @@ public:
ptr p = { asio::detail::addressof(o->handler_), o, o };
handler_work<Handler> w(o->handler_);
if (owner && owner != &o->io_service_impl_)
if (owner && owner != &o->io_context_impl_)
{
// The operation is being run on the worker io_service. Time to perform
// The operation is being run on the worker io_context. Time to perform
// the resolver operation.
// Perform the blocking host resolution operation.
@ -79,13 +79,13 @@ public:
o->query_.host_name().c_str(), o->query_.service_name().c_str(),
o->query_.hints(), &o->addrinfo_, o->ec_);
// Pass operation back to main io_service for completion.
o->io_service_impl_.post_deferred_completion(o);
// Pass operation back to main io_context for completion.
o->io_context_impl_.post_deferred_completion(o);
p.v = p.p = 0;
}
else
{
// The operation has been returned to the main io_service. The completion
// The operation has been returned to the main io_context. The completion
// handler is ready to be delivered.
ASIO_HANDLER_COMPLETION((*o));
@ -119,7 +119,7 @@ public:
private:
socket_ops::weak_cancel_token_type cancel_token_;
query_type query_;
io_service_impl& io_service_impl_;
io_context_impl& io_context_impl_;
Handler handler_;
asio::error_code ec_;
asio::detail::addrinfo_type* addrinfo_;

View File

@ -49,8 +49,8 @@ public:
typedef asio::ip::basic_resolver_results<Protocol> results_type;
// Constructor.
resolver_service(asio::io_service& io_service)
: resolver_service_base(io_service)
resolver_service(asio::io_context& io_context)
: resolver_service_base(io_context)
{
}
@ -77,9 +77,9 @@ public:
typedef resolve_op<Protocol, Handler> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl, query, io_service_impl_, handler);
p.p = new (p.v) op(impl, query, io_context_impl_, handler);
ASIO_HANDLER_CREATION((io_service_impl_.context(),
ASIO_HANDLER_CREATION((io_context_impl_.context(),
*p.p, "resolver", &impl, 0, "async_resolve"));
start_resolve_op(p.p);
@ -109,9 +109,9 @@ public:
typedef resolve_endpoint_op<Protocol, Handler> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl, endpoint, io_service_impl_, handler);
p.p = new (p.v) op(impl, endpoint, io_context_impl_, handler);
ASIO_HANDLER_CREATION((io_service_impl_.context(),
ASIO_HANDLER_CREATION((io_context_impl_.context(),
*p.p, "resolver", &impl, 0, "async_resolve"));
start_resolve_op(p.p);

View File

@ -17,7 +17,7 @@
#include "asio/detail/config.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/mutex.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/operation.hpp"
@ -39,7 +39,7 @@ public:
typedef socket_ops::shared_cancel_token_type implementation_type;
// Constructor.
ASIO_DECL resolver_service_base(asio::io_service& io_service);
ASIO_DECL resolver_service_base(asio::io_context& io_context);
// Destructor.
ASIO_DECL ~resolver_service_base();
@ -49,7 +49,7 @@ public:
// Perform any fork-related housekeeping.
ASIO_DECL void fork_service(
asio::io_service::fork_event fork_ev);
asio::io_context::fork_event fork_ev);
// Construct a new resolver implementation.
ASIO_DECL void construct(implementation_type& impl);
@ -91,29 +91,29 @@ protected:
};
#endif // !defined(ASIO_WINDOWS_RUNTIME)
// Helper class to run the work io_service in a thread.
class work_io_service_runner;
// Helper class to run the work io_context in a thread.
class work_io_context_runner;
// Start the work thread if it's not already running.
ASIO_DECL void start_work_thread();
// The io_service implementation used to post completions.
io_service_impl& io_service_impl_;
// The io_context implementation used to post completions.
io_context_impl& io_context_impl_;
private:
// Mutex to protect access to internal data.
asio::detail::mutex mutex_;
// Private io_service used for performing asynchronous host resolution.
asio::detail::scoped_ptr<asio::io_service> work_io_service_;
// Private io_context used for performing asynchronous host resolution.
asio::detail::scoped_ptr<asio::io_context> work_io_context_;
// The work io_service implementation used to post completions.
io_service_impl& work_io_service_impl_;
// The work io_context implementation used to post completions.
io_context_impl& work_io_context_impl_;
// Work for the private io_service to perform.
asio::detail::scoped_ptr<asio::io_service::work> work_;
// Work for the private io_context to perform.
asio::detail::scoped_ptr<asio::io_context::work> work_;
// Thread used for running the work io_service's run loop.
// Thread used for running the work io_context's run loop.
asio::detail::scoped_ptr<asio::detail::thread> work_thread_;
};

View File

@ -175,7 +175,7 @@ private:
// The scheduler implementation used to post completions.
# if defined(ASIO_HAS_IOCP)
typedef class win_iocp_io_service scheduler_type;
typedef class win_iocp_io_context scheduler_type;
# else // defined(ASIO_HAS_IOCP)
typedef class scheduler scheduler_type;
# endif // defined(ASIO_HAS_IOCP)

View File

@ -25,7 +25,7 @@
namespace asio {
class io_service;
class io_context;
namespace detail {
@ -61,9 +61,9 @@ public:
// create a new service object automatically if no such object already
// exists. Ownership of the service object is not transferred to the caller.
// This overload is used for backwards compatibility with services that
// inherit from io_service::service.
// inherit from io_context::service.
template <typename Service>
Service& use_service(io_service& owner);
Service& use_service(io_context& owner);
// Add a service object. Throws on error, in which case ownership of the
// object is retained by the caller.

View File

@ -20,7 +20,7 @@
#include <cstddef>
#include <signal.h>
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/handler_alloc_helpers.hpp"
#include "asio/detail/memory.hpp"
#include "asio/detail/op_queue.hpp"
@ -108,7 +108,7 @@ public:
};
// Constructor.
ASIO_DECL signal_set_service(asio::io_service& io_service);
ASIO_DECL signal_set_service(asio::io_context& io_context);
// Destructor.
ASIO_DECL ~signal_set_service();
@ -118,7 +118,7 @@ public:
// Perform fork-related housekeeping.
ASIO_DECL void fork_service(
asio::io_service::fork_event fork_ev);
asio::io_context::fork_event fork_ev);
// Construct a new signal_set implementation.
ASIO_DECL void construct(implementation_type& impl);
@ -152,7 +152,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(handler);
ASIO_HANDLER_CREATION((io_service_.context(),
ASIO_HANDLER_CREATION((io_context_.context(),
*p.p, "signal_set", &impl, 0, "async_wait"));
start_wait_op(impl, p.p);
@ -178,8 +178,8 @@ private:
// Helper function to start a wait operation.
ASIO_DECL void start_wait_op(implementation_type& impl, signal_op* op);
// The io_service instance used for dispatching handlers.
io_service_impl& io_service_;
// The io_context instance used for dispatching handlers.
io_context_impl& io_context_;
#if !defined(ASIO_WINDOWS) \
&& !defined(ASIO_WINDOWS_RUNTIME) \

View File

@ -16,7 +16,7 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/mutex.hpp"
#include "asio/detail/op_queue.hpp"
#include "asio/detail/operation.hpp"
@ -74,8 +74,8 @@ public:
typedef strand_impl* implementation_type;
// Construct a new strand service for the specified io_service.
ASIO_DECL explicit strand_service(asio::io_service& io_service);
// Construct a new strand service for the specified io_context.
ASIO_DECL explicit strand_service(asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();
@ -83,11 +83,11 @@ public:
// Construct a new strand implementation.
ASIO_DECL void construct(implementation_type& impl);
// Request the io_service to invoke the given handler.
// Request the io_context to invoke the given handler.
template <typename Handler>
void dispatch(implementation_type& impl, Handler& handler);
// Request the io_service to invoke the given handler and return immediately.
// Request the io_context to invoke the given handler and return immediately.
template <typename Handler>
void post(implementation_type& impl, Handler& handler);
@ -108,8 +108,8 @@ private:
operation* base, const asio::error_code& ec,
std::size_t bytes_transferred);
// The io_service implementation used to post completions.
io_service_impl& io_service_;
// The io_context implementation used to post completions.
io_context_impl& io_context_;
// Mutex to protect access to the array of implementations.
asio::detail::mutex mutex_;

View File

@ -26,7 +26,7 @@ namespace detail {
class thread_info_base;
// Base class for things that manage threads (scheduler, win_iocp_io_service).
// Base class for things that manage threads (scheduler, win_iocp_io_context).
class thread_context
{
public:

View File

@ -21,7 +21,7 @@
#if defined(ASIO_WINDOWS_RUNTIME)
# include "asio/detail/winrt_timer_scheduler.hpp"
#elif defined(ASIO_HAS_IOCP)
# include "asio/detail/win_iocp_io_service.hpp"
# include "asio/detail/win_iocp_io_context.hpp"
#elif defined(ASIO_HAS_EPOLL)
# include "asio/detail/epoll_reactor.hpp"
#elif defined(ASIO_HAS_KQUEUE)

View File

@ -23,7 +23,7 @@ namespace detail {
#if defined(ASIO_WINDOWS_RUNTIME)
typedef class winrt_timer_scheduler timer_scheduler;
#elif defined(ASIO_HAS_IOCP)
typedef class win_iocp_io_service timer_scheduler;
typedef class win_iocp_io_context timer_scheduler;
#elif defined(ASIO_HAS_EPOLL)
typedef class epoll_reactor timer_scheduler;
#elif defined(ASIO_HAS_KQUEUE)

View File

@ -21,7 +21,7 @@
#include "asio/detail/handler_invoke_helpers.hpp"
#include "asio/detail/memory.hpp"
#include "asio/detail/wait_op.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"

View File

@ -21,7 +21,7 @@
#if defined(ASIO_HAS_IOCP)
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
#include "asio/detail/cstdint.hpp"
#include "asio/detail/handler_alloc_helpers.hpp"
@ -30,7 +30,7 @@
#include "asio/detail/operation.hpp"
#include "asio/detail/win_iocp_handle_read_op.hpp"
#include "asio/detail/win_iocp_handle_write_op.hpp"
#include "asio/detail/win_iocp_io_service.hpp"
#include "asio/detail/win_iocp_io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -74,7 +74,7 @@ public:
implementation_type* prev_;
};
ASIO_DECL win_iocp_handle_service(asio::io_service& io_service);
ASIO_DECL win_iocp_handle_service(asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();
@ -299,7 +299,7 @@ private:
// The IOCP service used for running asynchronous operations and dispatching
// handlers.
win_iocp_io_service& iocp_service_;
win_iocp_io_context& iocp_service_;
// Mutex to protect access to the linked list of implementations.
mutex mutex_;

View File

@ -1,5 +1,5 @@
//
// detail/win_iocp_io_service.hpp
// detail/win_iocp_io_context.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
@ -8,8 +8,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP
#define ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP
#ifndef ASIO_DETAIL_WIN_IOCP_IO_CONTEXT_HPP
#define ASIO_DETAIL_WIN_IOCP_IO_CONTEXT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
@ -40,14 +40,14 @@ namespace detail {
class wait_op;
class win_iocp_io_service
: public execution_context_service_base<win_iocp_io_service>,
class win_iocp_io_context
: public execution_context_service_base<win_iocp_io_context>,
public thread_context
{
public:
// Constructor. Specifies a concurrency hint that is passed through to the
// underlying I/O completion port.
ASIO_DECL win_iocp_io_service(asio::execution_context& ctx,
ASIO_DECL win_iocp_io_context(asio::execution_context& ctx,
size_t concurrency_hint = 0);
// Destroy all user-defined handler objects owned by the service.
@ -77,7 +77,7 @@ public:
// Stop the event processing loop.
ASIO_DECL void stop();
// Determine whether the io_service is stopped.
// Determine whether the io_context is stopped.
bool stopped() const
{
return ::InterlockedExchangeAdd(&stopped_, 0) != 0;
@ -306,11 +306,11 @@ private:
#include "asio/detail/pop_options.hpp"
#include "asio/detail/impl/win_iocp_io_service.hpp"
#include "asio/detail/impl/win_iocp_io_context.hpp"
#if defined(ASIO_HEADER_ONLY)
# include "asio/detail/impl/win_iocp_io_service.ipp"
# include "asio/detail/impl/win_iocp_io_context.ipp"
#endif // defined(ASIO_HEADER_ONLY)
#endif // defined(ASIO_HAS_IOCP)
#endif // ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP
#endif // ASIO_DETAIL_WIN_IOCP_IO_CONTEXT_HPP

View File

@ -29,7 +29,7 @@
namespace asio {
namespace detail {
class win_iocp_io_service;
class win_iocp_io_context;
// Base class for all operations. A function pointer is used instead of virtual
// functions to avoid the associated overhead.
@ -80,7 +80,7 @@ protected:
private:
friend class op_queue_access;
friend class win_iocp_io_service;
friend class win_iocp_io_context;
win_iocp_operation* next_;
func_type func_;
long ready_;

View File

@ -19,12 +19,12 @@
#if defined(ASIO_HAS_IOCP)
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/handler_alloc_helpers.hpp"
#include "asio/detail/memory.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/win_iocp_overlapped_op.hpp"
#include "asio/detail/win_iocp_io_service.hpp"
#include "asio/detail/win_iocp_io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -46,11 +46,11 @@ public:
// Construct an win_iocp_overlapped_ptr to contain the specified handler.
template <typename Handler>
explicit win_iocp_overlapped_ptr(
asio::io_service& io_service, ASIO_MOVE_ARG(Handler) handler)
asio::io_context& io_context, ASIO_MOVE_ARG(Handler) handler)
: ptr_(0),
iocp_service_(0)
{
this->reset(io_service, ASIO_MOVE_CAST(Handler)(handler));
this->reset(io_context, ASIO_MOVE_CAST(Handler)(handler));
}
// Destructor automatically frees the OVERLAPPED object unless released.
@ -74,21 +74,21 @@ public:
// Reset to contain the specified handler, freeing any current OVERLAPPED
// object.
template <typename Handler>
void reset(asio::io_service& io_service, Handler handler)
void reset(asio::io_context& io_context, Handler handler)
{
typedef win_iocp_overlapped_op<Handler> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(handler);
ASIO_HANDLER_CREATION((io_service, *p.p,
"io_service", &io_service.impl_, 0, "overlapped"));
ASIO_HANDLER_CREATION((io_context, *p.p,
"io_context", &io_context.impl_, 0, "overlapped"));
io_service.impl_.work_started();
io_context.impl_.work_started();
reset();
ptr_ = p.p;
p.v = p.p = 0;
iocp_service_ = &io_service.impl_;
iocp_service_ = &io_context.impl_;
}
// Get the contained OVERLAPPED object.
@ -130,7 +130,7 @@ public:
private:
win_iocp_operation* ptr_;
win_iocp_io_service* iocp_service_;
win_iocp_io_context* iocp_service_;
};
} // namespace detail

View File

@ -22,7 +22,7 @@
#include <string>
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/win_iocp_handle_service.hpp"
#include "asio/detail/push_options.hpp"
@ -42,7 +42,7 @@ public:
// Constructor.
ASIO_DECL win_iocp_serial_port_service(
asio::io_service& io_service);
asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();

View File

@ -167,13 +167,13 @@ public:
win_iocp_socket_move_accept_op(
win_iocp_socket_service_base& socket_service, socket_type socket,
const Protocol& protocol, asio::io_service& peer_io_service,
const Protocol& protocol, asio::io_context& peer_io_context,
typename Protocol::endpoint* peer_endpoint,
bool enable_connection_aborted, Handler& handler)
: operation(&win_iocp_socket_move_accept_op::do_complete),
socket_service_(socket_service),
socket_(socket),
peer_(peer_io_service),
peer_(peer_io_context),
protocol_(protocol),
peer_endpoint_(peer_endpoint),
enable_connection_aborted_(enable_connection_aborted),

View File

@ -21,7 +21,7 @@
#include <cstring>
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/bind_handler.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
@ -36,7 +36,7 @@
#include "asio/detail/socket_holder.hpp"
#include "asio/detail/socket_ops.hpp"
#include "asio/detail/socket_types.hpp"
#include "asio/detail/win_iocp_io_service.hpp"
#include "asio/detail/win_iocp_io_context.hpp"
#include "asio/detail/win_iocp_null_buffers_op.hpp"
#include "asio/detail/win_iocp_socket_accept_op.hpp"
#include "asio/detail/win_iocp_socket_connect_op.hpp"
@ -127,8 +127,8 @@ public:
};
// Constructor.
win_iocp_socket_service(asio::io_service& io_service)
: win_iocp_socket_service_base(io_service)
win_iocp_socket_service(asio::io_context& io_context)
: win_iocp_socket_service_base(io_context)
{
}
@ -316,7 +316,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, buffers, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_send_to"));
buffer_sequence_adapter<asio::const_buffer,
@ -339,7 +339,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_send_to(null_buffers)"));
start_reactor_op(impl, select_reactor::write_op, p.p);
@ -397,7 +397,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(sender_endp, impl.cancel_token_, buffers, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_receive_from"));
buffer_sequence_adapter<asio::mutable_buffer,
@ -420,7 +420,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_receive_from(null_buffers)"));
// Reset endpoint since it can be given no sensible value at this time.
@ -462,11 +462,11 @@ public:
#if defined(ASIO_HAS_MOVE)
// Accept a new connection.
typename Protocol::socket accept(implementation_type& impl,
io_service* peer_io_service, endpoint_type* peer_endpoint,
io_context* peer_io_context, endpoint_type* peer_endpoint,
asio::error_code& ec)
{
typename Protocol::socket peer(
peer_io_service ? *peer_io_service : io_service_);
peer_io_context ? *peer_io_context : io_context_);
std::size_t addr_len = peer_endpoint ? peer_endpoint->capacity() : 0;
socket_holder new_socket(socket_ops::sync_accept(impl.socket_,
@ -501,7 +501,7 @@ public:
p.p = new (p.v) op(*this, impl.socket_, peer, impl.protocol_,
peer_endpoint, enable_connection_aborted, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_accept"));
start_accept_op(impl, peer.is_open(), p.p->new_socket(),
@ -516,7 +516,7 @@ public:
// must be valid until the accept's handler is invoked.
template <typename Handler>
void async_accept(implementation_type& impl,
asio::io_service* peer_io_service,
asio::io_context* peer_io_context,
endpoint_type* peer_endpoint, Handler& handler)
{
// Allocate and construct an operation to wrap the handler.
@ -526,10 +526,10 @@ public:
bool enable_connection_aborted =
(impl.state_ & socket_ops::enable_connection_aborted) != 0;
p.p = new (p.v) op(*this, impl.socket_, impl.protocol_,
peer_io_service ? *peer_io_service : io_service_,
peer_io_context ? *peer_io_context : io_context_,
peer_endpoint, enable_connection_aborted, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_accept"));
start_accept_op(impl, false, p.p->new_socket(),
@ -560,7 +560,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.socket_, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_connect"));
start_connect_op(impl, impl.protocol_.family(), impl.protocol_.type(),

View File

@ -20,7 +20,7 @@
#if defined(ASIO_HAS_IOCP)
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/bind_handler.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
@ -35,7 +35,7 @@
#include "asio/detail/socket_holder.hpp"
#include "asio/detail/socket_ops.hpp"
#include "asio/detail/socket_types.hpp"
#include "asio/detail/win_iocp_io_service.hpp"
#include "asio/detail/win_iocp_io_context.hpp"
#include "asio/detail/win_iocp_null_buffers_op.hpp"
#include "asio/detail/win_iocp_socket_connect_op.hpp"
#include "asio/detail/win_iocp_socket_send_op.hpp"
@ -86,7 +86,7 @@ public:
// Constructor.
ASIO_DECL win_iocp_socket_service_base(
asio::io_service& io_service);
asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();
@ -227,7 +227,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_wait"));
switch (w)
@ -286,7 +286,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, buffers, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_send"));
buffer_sequence_adapter<asio::const_buffer,
@ -309,7 +309,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_send(null_buffers)"));
start_reactor_op(impl, select_reactor::write_op, p.p);
@ -352,7 +352,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.state_, impl.cancel_token_, buffers, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_receive"));
buffer_sequence_adapter<asio::mutable_buffer,
@ -375,7 +375,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_receive(null_buffers)"));
start_null_buffers_receive_op(impl, flags, p.p);
@ -425,7 +425,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, buffers, out_flags, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_receive_with_flags"));
buffer_sequence_adapter<asio::mutable_buffer,
@ -447,7 +447,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(impl.cancel_token_, handler);
ASIO_HANDLER_CREATION((io_service_, *p.p, "socket",
ASIO_HANDLER_CREATION((io_context_, *p.p, "socket",
&impl, impl.socket_, "async_receive_with_flags(null_buffers)"));
// Reset out_flags since it can be given no sensible value at this time.
@ -522,7 +522,7 @@ protected:
base_implementation_type& impl);
// Helper function to get the reactor. If no reactor has been created yet, a
// new one is obtained from the io_service and a pointer to it is cached in
// new one is obtained from the io_context and a pointer to it is cached in
// this service.
ASIO_DECL select_reactor& get_reactor();
@ -548,12 +548,12 @@ protected:
// - platform SDKs where MSVC's /Wp64 option causes spurious warnings.
ASIO_DECL void* interlocked_exchange_pointer(void** dest, void* val);
// The io_service used to obtain the reactor, if required.
asio::io_service& io_service_;
// The io_context used to obtain the reactor, if required.
asio::io_context& io_context_;
// The IOCP service used for running asynchronous operations and dispatching
// handlers.
win_iocp_io_service& iocp_service_;
win_iocp_io_context& iocp_service_;
// The reactor used for performing connect operations. This object is created
// only if needed.

View File

@ -24,7 +24,7 @@
#include "asio/detail/memory.hpp"
#include "asio/detail/wait_handler.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -79,7 +79,7 @@ public:
// Constructor.
ASIO_DECL win_object_handle_service(
asio::io_service& io_service);
asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();
@ -137,7 +137,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(handler);
ASIO_HANDLER_CREATION((io_service_.context(), *p.p, "object_handle",
ASIO_HANDLER_CREATION((io_context_.context(), *p.p, "object_handle",
&impl, reinterpret_cast<uintmax_t>(impl.wait_handle_), "async_wait"));
start_wait_op(impl, p.p);
@ -156,8 +156,8 @@ private:
static ASIO_DECL VOID CALLBACK wait_callback(
PVOID param, BOOLEAN timeout);
// The io_service implementation used to post completions.
io_service_impl& io_service_;
// The io_context implementation used to post completions.
io_context_impl& io_context_;
// Mutex to protect access to internal state.
mutex mutex_;

View File

@ -23,7 +23,7 @@
#include "asio/detail/atomic_count.hpp"
#include "asio/detail/winrt_async_op.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -35,9 +35,9 @@ class winrt_async_manager
{
public:
// Constructor.
winrt_async_manager(asio::io_service& io_service)
: asio::detail::service_base<winrt_async_manager>(io_service),
io_service_(use_service<io_service_impl>(io_service)),
winrt_async_manager(asio::io_context& io_context)
: asio::detail::service_base<winrt_async_manager>(io_context),
io_context_(use_service<io_context_impl>(io_context)),
outstanding_ops_(1)
{
}
@ -185,12 +185,12 @@ public:
asio::system_category());
break;
}
io_service_.post_deferred_completion(handler);
io_context_.post_deferred_completion(handler);
if (--outstanding_ops_ == 0)
promise_.set_value();
});
io_service_.work_started();
io_context_.work_started();
++outstanding_ops_;
action->Completed = on_completed;
}
@ -222,12 +222,12 @@ public:
asio::system_category());
break;
}
io_service_.post_deferred_completion(handler);
io_context_.post_deferred_completion(handler);
if (--outstanding_ops_ == 0)
promise_.set_value();
});
io_service_.work_started();
io_context_.work_started();
++outstanding_ops_;
operation->Completed = on_completed;
}
@ -263,19 +263,19 @@ public:
asio::system_category());
break;
}
io_service_.post_deferred_completion(handler);
io_context_.post_deferred_completion(handler);
if (--outstanding_ops_ == 0)
promise_.set_value();
});
io_service_.work_started();
io_context_.work_started();
++outstanding_ops_;
operation->Completed = on_completed;
}
private:
// The io_service implementation used to post completed handlers.
io_service_impl& io_service_;
// The io_context implementation used to post completed handlers.
io_context_impl& io_context_;
// Count of outstanding operations.
atomic_count outstanding_ops_;

View File

@ -52,9 +52,9 @@ public:
typedef asio::ip::basic_resolver_results<Protocol> results_type;
// Constructor.
winrt_resolver_service(asio::io_service& io_service)
: io_service_(use_service<io_service_impl>(io_service)),
async_manager_(use_service<winrt_async_manager>(io_service))
winrt_resolver_service(asio::io_context& io_context)
: io_context_(use_service<io_context_impl>(io_context)),
async_manager_(use_service<winrt_async_manager>(io_context))
{
}
@ -69,7 +69,7 @@ public:
}
// Perform any fork-related housekeeping.
void fork_service(asio::io_service::fork_event)
void fork_service(asio::io_context::fork_event)
{
}
@ -129,7 +129,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(query, handler);
ASIO_HANDLER_CREATION((io_service_.context(),
ASIO_HANDLER_CREATION((io_context_.context(),
*p.p, "resolver", &impl, 0, "async_resolve"));
(void)impl;
@ -145,7 +145,7 @@ public:
{
p.p->ec_ = asio::error_code(
e->HResult, asio::system_category());
io_service_.post_immediate_completion(p.p, is_continuation);
io_context_.post_immediate_completion(p.p, is_continuation);
p.v = p.p = 0;
}
}
@ -165,12 +165,12 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const results_type results;
io_service_.get_io_service().post(
io_context_.get_io_context().post(
detail::bind_handler(handler, ec, results));
}
private:
io_service_impl& io_service_;
io_context_impl& io_context_;
winrt_async_manager& async_manager_;
};

View File

@ -20,7 +20,7 @@
#if defined(ASIO_WINDOWS_RUNTIME)
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/memory.hpp"
#include "asio/detail/winrt_socket_connect_op.hpp"
#include "asio/detail/winrt_ssocket_service_base.hpp"
@ -60,8 +60,8 @@ public:
};
// Constructor.
winrt_ssocket_service(asio::io_service& io_service)
: winrt_ssocket_service_base(io_service)
winrt_ssocket_service(asio::io_context& io_context)
: winrt_ssocket_service_base(io_context)
{
}
@ -214,7 +214,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(handler);
ASIO_HANDLER_CREATION((io_service_.context(),
ASIO_HANDLER_CREATION((io_context_.context(),
*p.p, "socket", &impl, 0, "async_connect"));
start_connect_op(impl, peer_endpoint.data(), p.p, is_continuation);

View File

@ -21,7 +21,7 @@
#include "asio/buffer.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
#include "asio/detail/memory.hpp"
@ -62,7 +62,7 @@ public:
// Constructor.
ASIO_DECL winrt_ssocket_service_base(
asio::io_service& io_service);
asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service();
@ -202,7 +202,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(buffers, handler);
ASIO_HANDLER_CREATION((io_service_.context(),
ASIO_HANDLER_CREATION((io_context_.context(),
*p.p, "socket", &impl, 0, "async_send"));
start_send_op(impl,
@ -219,7 +219,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.get_io_service().post(
io_context_.get_io_context().post(
detail::bind_handler(handler, ec, bytes_transferred));
}
@ -258,7 +258,7 @@ public:
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(buffers, handler);
ASIO_HANDLER_CREATION((io_service_.context(),
ASIO_HANDLER_CREATION((io_context_.context(),
*p.p, "socket", &impl, 0, "async_receive"));
start_receive_op(impl,
@ -275,7 +275,7 @@ public:
{
asio::error_code ec = asio::error::operation_not_supported;
const std::size_t bytes_transferred = 0;
io_service_.get_io_service().post(
io_context_.get_io_context().post(
detail::bind_handler(handler, ec, bytes_transferred));
}
@ -328,8 +328,8 @@ protected:
winrt_async_op<Windows::Storage::Streams::IBuffer^>* op,
bool is_continuation);
// The io_service implementation used for delivering completions.
io_service_impl& io_service_;
// The io_context implementation used for delivering completions.
io_context_impl& io_context_;
// The manager that keeps track of outstanding operations.
winrt_async_manager& async_manager_;

View File

@ -28,7 +28,7 @@
#include "asio/detail/timer_queue_base.hpp"
#include "asio/detail/timer_queue_set.hpp"
#include "asio/detail/wait_op.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#if defined(ASIO_HAS_IOCP)
# include "asio/detail/thread.hpp"
@ -44,7 +44,7 @@ class winrt_timer_scheduler
{
public:
// Constructor.
ASIO_DECL winrt_timer_scheduler(asio::io_service& io_service);
ASIO_DECL winrt_timer_scheduler(asio::io_context& io_context);
// Destructor.
ASIO_DECL ~winrt_timer_scheduler();
@ -54,7 +54,7 @@ public:
// Recreate internal descriptors following a fork.
ASIO_DECL void fork_service(
asio::io_service::fork_event fork_ev);
asio::io_context::fork_event fork_ev);
// Initialise the task. No effect as this class uses its own thread.
ASIO_DECL void init_task();
@ -100,8 +100,8 @@ private:
// Helper function to remove a timer queue.
ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue);
// The io_service implementation used to post completions.
io_service_impl& io_service_;
// The io_context implementation used to post completions.
io_context_impl& io_context_;
// Mutex used to protect internal variables.
asio::detail::mutex mutex_;

View File

@ -27,11 +27,11 @@
namespace asio {
class execution_context;
class io_service;
class io_context;
#if !defined(GENERATING_DOCUMENTATION)
template <typename Service> Service& use_service(execution_context&);
template <typename Service> Service& use_service(io_service&);
template <typename Service> Service& use_service(io_context&);
template <typename Service> void add_service(execution_context&, Service*);
template <typename Service> bool has_service(execution_context&);
#endif // !defined(ASIO_NO_DEPRECATED)
@ -41,7 +41,7 @@ namespace detail { class service_registry; }
/// A context for function object execution.
/**
* An execution context represents a place where function objects will be
* executed. An @c io_service is an example of an execution context.
* executed. An @c io_context is an example of an execution context.
*
* @par The execution_context class and services
*
@ -79,7 +79,7 @@ namespace detail { class service_registry; }
* @par The execution_context as a base class
*
* Class execution_context may be used only as a base class for concrete
* execution context types. The @c io_service is an example of such a derived
* execution context types. The @c io_context is an example of such a derived
* type.
*
* On destruction, a class that is derived from execution_context must perform
@ -96,8 +96,8 @@ namespace detail { class service_registry; }
* complete. The corresponding handler objects are destroyed, and all @c
* shared_ptr references to the objects are destroyed.
*
* @li To shut down the whole program, the io_service function stop() is called
* to terminate any run() calls as soon as possible. The io_service destructor
* @li To shut down the whole program, the io_context function stop() is called
* to terminate any run() calls as soon as possible. The io_context destructor
* calls @c shutdown_context() and @c destroy_context() to destroy all pending
* handlers, causing all @c shared_ptr references to all connection objects to
* be destroyed.
@ -210,18 +210,18 @@ public:
/**
* This function is used to locate a service object that corresponds to the
* given service type. If there is no existing implementation of the service,
* then the io_service will create a new instance of the service.
* then the io_context will create a new instance of the service.
*
* @param ios The io_service object that owns the service.
* @param ioc The io_context object that owns the service.
*
* @return The service interface implementing the specified service type.
* Ownership of the service interface is not transferred to the caller.
*
* @note This overload is preserved for backwards compatibility with services
* that inherit from io_service::service.
* that inherit from io_context::service.
*/
template <typename Service>
friend Service& use_service(io_service& ios);
friend Service& use_service(io_context& ioc);
#if defined(GENERATING_DOCUMENTATION)
@ -310,7 +310,7 @@ public:
id() {}
};
/// Base class for all io_service services.
/// Base class for all io_context services.
class execution_context::service
: private noncopyable
{

View File

@ -26,12 +26,12 @@ namespace asio {
* @brief Default invoke function for handlers.
*
* Completion handlers for asynchronous operations are invoked by the
* io_service associated with the corresponding object (e.g. a socket or
* io_context associated with the corresponding object (e.g. a socket or
* deadline_timer). Certain guarantees are made on when the handler may be
* invoked, in particular that a handler can only be invoked from a thread that
* is currently calling @c run() on the corresponding io_service object.
* is currently calling @c run() on the corresponding io_context object.
* Handlers may subsequently be invoked through other objects (such as
* io_service::strand objects) that provide additional guarantees.
* io_context::strand objects) that provide additional guarantees.
*
* When asynchronous operations are composed from other asynchronous
* operations, all intermediate handlers should be invoked using the same

View File

@ -1,5 +1,5 @@
//
// impl/io_service.hpp
// impl/io_context.hpp
// ~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
@ -8,8 +8,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_IMPL_IO_SERVICE_HPP
#define ASIO_IMPL_IO_SERVICE_HPP
#ifndef ASIO_IMPL_IO_CONTEXT_HPP
#define ASIO_IMPL_IO_CONTEXT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
@ -28,20 +28,20 @@
namespace asio {
template <typename Service>
inline Service& use_service(io_service& ios)
inline Service& use_service(io_context& ioc)
{
// Check that Service meets the necessary type requirements.
(void)static_cast<execution_context::service*>(static_cast<Service*>(0));
(void)static_cast<const execution_context::id*>(&Service::id);
return ios.service_registry_->template use_service<Service>(ios);
return ioc.service_registry_->template use_service<Service>(ioc);
}
template <>
inline detail::io_service_impl& use_service<detail::io_service_impl>(
io_service& ios)
inline detail::io_context_impl& use_service<detail::io_context_impl>(
io_context& ioc)
{
return ios.impl_;
return ioc.impl_;
}
} // namespace asio
@ -49,7 +49,7 @@ inline detail::io_service_impl& use_service<detail::io_service_impl>(
#include "asio/detail/pop_options.hpp"
#if defined(ASIO_HAS_IOCP)
# include "asio/detail/win_iocp_io_service.hpp"
# include "asio/detail/win_iocp_io_context.hpp"
#else
# include "asio/detail/scheduler.hpp"
#endif
@ -58,22 +58,22 @@ inline detail::io_service_impl& use_service<detail::io_service_impl>(
namespace asio {
inline io_service::executor_type
io_service::get_executor() ASIO_NOEXCEPT
inline io_context::executor_type
io_context::get_executor() ASIO_NOEXCEPT
{
return executor_type(*this);
}
#if !defined(ASIO_NO_DEPRECATED)
inline void io_service::reset()
inline void io_context::reset()
{
restart();
}
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
io_service::dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
io_context::dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
@ -96,7 +96,7 @@ io_service::dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
p.p = new (p.v) op(init.handler);
ASIO_HANDLER_CREATION((*this, *p.p,
"io_service", this, 0, "dispatch"));
"io_context", this, 0, "dispatch"));
impl_.do_dispatch(p.p);
p.v = p.p = 0;
@ -107,7 +107,7 @@ io_service::dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
io_service::post(ASIO_MOVE_ARG(CompletionHandler) handler)
io_context::post(ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
@ -126,7 +126,7 @@ io_service::post(ASIO_MOVE_ARG(CompletionHandler) handler)
p.p = new (p.v) op(init.handler);
ASIO_HANDLER_CREATION((*this, *p.p,
"io_service", this, 0, "post"));
"io_context", this, 0, "post"));
impl_.post_immediate_completion(p.p, is_continuation);
p.v = p.p = 0;
@ -138,33 +138,33 @@ template <typename Handler>
#if defined(GENERATING_DOCUMENTATION)
unspecified
#else
inline detail::wrapped_handler<io_service&, Handler>
inline detail::wrapped_handler<io_context&, Handler>
#endif
io_service::wrap(Handler handler)
io_context::wrap(Handler handler)
{
return detail::wrapped_handler<io_service&, Handler>(*this, handler);
return detail::wrapped_handler<io_context&, Handler>(*this, handler);
}
#endif // !defined(ASIO_NO_DEPRECATED)
inline io_service&
io_service::executor_type::context() ASIO_NOEXCEPT
inline io_context&
io_context::executor_type::context() ASIO_NOEXCEPT
{
return io_service_;
return io_context_;
}
inline void io_service::executor_type::on_work_started() ASIO_NOEXCEPT
inline void io_context::executor_type::on_work_started() ASIO_NOEXCEPT
{
io_service_.impl_.work_started();
io_context_.impl_.work_started();
}
inline void io_service::executor_type::on_work_finished() ASIO_NOEXCEPT
inline void io_context::executor_type::on_work_finished() ASIO_NOEXCEPT
{
io_service_.impl_.work_finished();
io_context_.impl_.work_finished();
}
template <typename Function, typename Allocator>
void io_service::executor_type::dispatch(
void io_context::executor_type::dispatch(
ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
// Make a local, non-const copy of the function.
@ -172,7 +172,7 @@ void io_service::executor_type::dispatch(
function_type tmp(ASIO_MOVE_CAST(Function)(f));
// Invoke immediately if we are already inside the thread pool.
if (io_service_.impl_.can_dispatch())
if (io_context_.impl_.can_dispatch())
{
detail::fenced_block b(detail::fenced_block::full);
asio_handler_invoke_helpers::invoke(tmp, tmp);
@ -190,14 +190,14 @@ void io_service::executor_type::dispatch(
p.p = new (p.v) op(tmp, allocator);
ASIO_HANDLER_CREATION((this->context(),
*p.p, "io_service", this, 0, "post"));
*p.p, "io_context", this, 0, "post"));
io_service_.impl_.post_immediate_completion(p.p, false);
io_context_.impl_.post_immediate_completion(p.p, false);
p.v = p.p = 0;
}
template <typename Function, typename Allocator>
void io_service::executor_type::post(
void io_context::executor_type::post(
ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
// Make a local, non-const copy of the function.
@ -215,14 +215,14 @@ void io_service::executor_type::post(
p.p = new (p.v) op(tmp, allocator);
ASIO_HANDLER_CREATION((this->context(),
*p.p, "io_service", this, 0, "post"));
*p.p, "io_context", this, 0, "post"));
io_service_.impl_.post_immediate_completion(p.p, false);
io_context_.impl_.post_immediate_completion(p.p, false);
p.v = p.p = 0;
}
template <typename Function, typename Allocator>
void io_service::executor_type::defer(
void io_context::executor_type::defer(
ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
// Make a local, non-const copy of the function.
@ -240,47 +240,61 @@ void io_service::executor_type::defer(
p.p = new (p.v) op(tmp, allocator);
ASIO_HANDLER_CREATION((this->context(),
*p.p, "io_service", this, 0, "defer"));
*p.p, "io_context", this, 0, "defer"));
io_service_.impl_.post_immediate_completion(p.p, true);
io_context_.impl_.post_immediate_completion(p.p, true);
p.v = p.p = 0;
}
inline bool
io_service::executor_type::running_in_this_thread() const ASIO_NOEXCEPT
io_context::executor_type::running_in_this_thread() const ASIO_NOEXCEPT
{
return io_service_.impl_.can_dispatch();
return io_context_.impl_.can_dispatch();
}
inline io_service::work::work(asio::io_service& io_service)
: io_service_impl_(io_service.impl_)
inline io_context::work::work(asio::io_context& io_context)
: io_context_impl_(io_context.impl_)
{
io_service_impl_.work_started();
io_context_impl_.work_started();
}
inline io_service::work::work(const work& other)
: io_service_impl_(other.io_service_impl_)
inline io_context::work::work(const work& other)
: io_context_impl_(other.io_context_impl_)
{
io_service_impl_.work_started();
io_context_impl_.work_started();
}
inline io_service::work::~work()
inline io_context::work::~work()
{
io_service_impl_.work_finished();
io_context_impl_.work_finished();
}
inline asio::io_service& io_service::work::get_io_service()
inline asio::io_context& io_context::work::get_io_context()
{
return static_cast<asio::io_service&>(io_service_impl_.context());
return static_cast<asio::io_context&>(io_context_impl_.context());
}
inline asio::io_service& io_service::service::get_io_service()
#if !defined(ASIO_NO_DEPRECATED)
inline asio::io_context& io_context::work::get_io_service()
{
return static_cast<asio::io_service&>(context());
return static_cast<asio::io_context&>(io_context_impl_.context());
}
#endif // !defined(ASIO_NO_DEPRECATED)
inline asio::io_context& io_context::service::get_io_context()
{
return static_cast<asio::io_context&>(context());
}
#if !defined(ASIO_NO_DEPRECATED)
inline asio::io_context& io_context::service::get_io_service()
{
return static_cast<asio::io_context&>(context());
}
#endif // !defined(ASIO_NO_DEPRECATED)
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // ASIO_IMPL_IO_SERVICE_HPP
#endif // ASIO_IMPL_IO_CONTEXT_HPP

View File

@ -1,5 +1,5 @@
//
// impl/io_service.ipp
// impl/io_context.ipp
// ~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
@ -8,22 +8,22 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_IMPL_IO_SERVICE_IPP
#define ASIO_IMPL_IO_SERVICE_IPP
#ifndef ASIO_IMPL_IO_CONTEXT_IPP
#define ASIO_IMPL_IO_CONTEXT_IPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/limits.hpp"
#include "asio/detail/scoped_ptr.hpp"
#include "asio/detail/service_registry.hpp"
#include "asio/detail/throw_error.hpp"
#if defined(ASIO_HAS_IOCP)
# include "asio/detail/win_iocp_io_service.hpp"
# include "asio/detail/win_iocp_io_context.hpp"
#else
# include "asio/detail/scheduler.hpp"
#endif
@ -32,17 +32,17 @@
namespace asio {
io_service::io_service()
io_context::io_context()
: impl_(create_impl())
{
}
io_service::io_service(std::size_t concurrency_hint)
io_context::io_context(std::size_t concurrency_hint)
: impl_(create_impl(concurrency_hint))
{
}
io_service::impl_type& io_service::create_impl(std::size_t concurrency_hint)
io_context::impl_type& io_context::create_impl(std::size_t concurrency_hint)
{
asio::detail::scoped_ptr<impl_type> impl(
new impl_type(*this, concurrency_hint));
@ -50,11 +50,11 @@ io_service::impl_type& io_service::create_impl(std::size_t concurrency_hint)
return *impl.release();
}
io_service::~io_service()
io_context::~io_context()
{
}
std::size_t io_service::run()
std::size_t io_context::run()
{
asio::error_code ec;
std::size_t s = impl_.run(ec);
@ -62,12 +62,12 @@ std::size_t io_service::run()
return s;
}
std::size_t io_service::run(asio::error_code& ec)
std::size_t io_context::run(asio::error_code& ec)
{
return impl_.run(ec);
}
std::size_t io_service::run_one()
std::size_t io_context::run_one()
{
asio::error_code ec;
std::size_t s = impl_.run_one(ec);
@ -75,12 +75,12 @@ std::size_t io_service::run_one()
return s;
}
std::size_t io_service::run_one(asio::error_code& ec)
std::size_t io_context::run_one(asio::error_code& ec)
{
return impl_.run_one(ec);
}
std::size_t io_service::poll()
std::size_t io_context::poll()
{
asio::error_code ec;
std::size_t s = impl_.poll(ec);
@ -88,12 +88,12 @@ std::size_t io_service::poll()
return s;
}
std::size_t io_service::poll(asio::error_code& ec)
std::size_t io_context::poll(asio::error_code& ec)
{
return impl_.poll(ec);
}
std::size_t io_service::poll_one()
std::size_t io_context::poll_one()
{
asio::error_code ec;
std::size_t s = impl_.poll_one(ec);
@ -101,32 +101,32 @@ std::size_t io_service::poll_one()
return s;
}
std::size_t io_service::poll_one(asio::error_code& ec)
std::size_t io_context::poll_one(asio::error_code& ec)
{
return impl_.poll_one(ec);
}
void io_service::stop()
void io_context::stop()
{
impl_.stop();
}
bool io_service::stopped() const
bool io_context::stopped() const
{
return impl_.stopped();
}
void io_service::restart()
void io_context::restart()
{
impl_.restart();
}
io_service::service::service(asio::io_service& owner)
io_context::service::service(asio::io_context& owner)
: execution_context::service(owner)
{
}
io_service::service::~service()
io_context::service::~service()
{
}
@ -134,4 +134,4 @@ io_service::service::~service()
#include "asio/detail/pop_options.hpp"
#endif // ASIO_IMPL_IO_SERVICE_IPP
#endif // ASIO_IMPL_IO_CONTEXT_IPP

View File

@ -423,7 +423,7 @@ inline void spawn(const strand<Executor>& ex,
}
template <typename Function>
inline void spawn(const asio::io_service::strand& s,
inline void spawn(const asio::io_context::strand& s,
ASIO_MOVE_ARG(Function) function,
const boost::coroutines::attributes& attributes)
{

View File

@ -24,7 +24,7 @@
#include "asio/impl/execution_context.ipp"
#include "asio/impl/executor.ipp"
#include "asio/impl/handler_alloc_hook.ipp"
#include "asio/impl/io_service.ipp"
#include "asio/impl/io_context.ipp"
#include "asio/impl/serial_port_base.ipp"
#include "asio/impl/system_executor.ipp"
#include "asio/impl/thread_pool.ipp"
@ -56,7 +56,7 @@
#include "asio/detail/impl/timer_queue_ptime.ipp"
#include "asio/detail/impl/timer_queue_set.ipp"
#include "asio/detail/impl/win_iocp_handle_service.ipp"
#include "asio/detail/impl/win_iocp_io_service.ipp"
#include "asio/detail/impl/win_iocp_io_context.ipp"
#include "asio/detail/impl/win_iocp_serial_port_service.ipp"
#include "asio/detail/impl/win_iocp_socket_service_base.ipp"
#include "asio/detail/impl/win_event.ipp"

View File

@ -0,0 +1,734 @@
//
// io_context.hpp
// ~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 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)
//
#ifndef ASIO_IO_CONTEXT_HPP
#define ASIO_IO_CONTEXT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include <cstddef>
#include <stdexcept>
#include <typeinfo>
#include "asio/async_result.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/wrapped_handler.hpp"
#include "asio/error_code.hpp"
#include "asio/execution_context.hpp"
#include "asio/is_executor.hpp"
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
# include "asio/detail/winsock_init.hpp"
#elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
|| defined(__osf__)
# include "asio/detail/signal_init.hpp"
#endif
#include "asio/detail/push_options.hpp"
namespace asio {
namespace detail {
#if defined(ASIO_HAS_IOCP)
typedef class win_iocp_io_context io_context_impl;
class win_iocp_overlapped_ptr;
#else
typedef class scheduler io_context_impl;
#endif
} // namespace detail
/// Provides core I/O functionality.
/**
* The io_context class provides the core I/O functionality for users of the
* asynchronous I/O objects, including:
*
* @li asio::ip::tcp::socket
* @li asio::ip::tcp::acceptor
* @li asio::ip::udp::socket
* @li asio::deadline_timer.
*
* The io_context class also includes facilities intended for developers of
* custom asynchronous services.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Safe, with the specific exceptions of the restart() and
* notify_fork() functions. Calling restart() while there are unfinished run(),
* run_one(), poll() or poll_one() calls results in undefined behaviour. The
* notify_fork() function should not be called while any io_context function,
* or any function on an I/O object that is associated with the io_context, is
* being called in another thread.
*
* @par Concepts:
* Dispatcher.
*
* @par Synchronous and asynchronous operations
*
* Synchronous operations on I/O objects implicitly run the io_context object
* for an individual operation. The io_context functions run(), run_one(),
* poll() or poll_one() must be called for the io_context to perform
* asynchronous operations on behalf of a C++ program. Notification that an
* asynchronous operation has completed is delivered by invocation of the
* associated handler. Handlers are invoked only by a thread that is currently
* calling any overload of run(), run_one(), poll() or poll_one() for the
* io_context.
*
* @par Effect of exceptions thrown from handlers
*
* If an exception is thrown from a handler, the exception is allowed to
* propagate through the throwing thread's invocation of run(), run_one(),
* poll() or poll_one(). No other threads that are calling any of these
* functions are affected. It is then the responsibility of the application to
* catch the exception.
*
* After the exception has been caught, the run(), run_one(), poll() or
* poll_one() call may be restarted @em without the need for an intervening
* call to restart(). This allows the thread to rejoin the io_context object's
* thread pool without impacting any other threads in the pool.
*
* For example:
*
* @code
* asio::io_context io_context;
* ...
* for (;;)
* {
* try
* {
* io_context.run();
* break; // run() exited normally
* }
* catch (my_exception& e)
* {
* // Deal with exception as appropriate.
* }
* }
* @endcode
*
* @par Stopping the io_context from running out of work
*
* Some applications may need to prevent an io_context object's run() call from
* returning when there is no more work to do. For example, the io_context may
* be being run in a background thread that is launched prior to the
* application's asynchronous operations. The run() call may be kept running by
* creating an object of type asio::io_context::work:
*
* @code asio::io_context io_context;
* asio::io_context::work work(io_context);
* ... @endcode
*
* To effect a shutdown, the application will then need to call the io_context
* object's stop() member function. This will cause the io_context run() call
* to return as soon as possible, abandoning unfinished operations and without
* permitting ready handlers to be dispatched.
*
* Alternatively, if the application requires that all operations and handlers
* be allowed to finish normally, the work object may be explicitly destroyed.
*
* @code asio::io_context io_context;
* auto_ptr<asio::io_context::work> work(
* new asio::io_context::work(io_context));
* ...
* work.reset(); // Allow run() to exit. @endcode
*/
class io_context
: public execution_context
{
private:
typedef detail::io_context_impl impl_type;
#if defined(ASIO_HAS_IOCP)
friend class detail::win_iocp_overlapped_ptr;
#endif
public:
class executor_type;
friend class executor_type;
class work;
friend class work;
class service;
class strand;
/// Constructor.
ASIO_DECL io_context();
/// Constructor.
/**
* Construct with a hint about the required level of concurrency.
*
* @param concurrency_hint A suggestion to the implementation on how many
* threads it should allow to run simultaneously.
*/
ASIO_DECL explicit io_context(std::size_t concurrency_hint);
/// Destructor.
/**
* On destruction, the io_context performs the following sequence of
* operations:
*
* @li For each service object @c svc in the io_context set, in reverse order
* of the beginning of service object lifetime, performs
* @c svc->shutdown_service().
*
* @li Uninvoked handler objects that were scheduled for deferred invocation
* on the io_context, or any associated strand, are destroyed.
*
* @li For each service object @c svc in the io_context set, in reverse order
* of the beginning of service object lifetime, performs
* <tt>delete static_cast<io_context::service*>(svc)</tt>.
*
* @note The destruction sequence described above permits programs to
* simplify their resource management by using @c shared_ptr<>. Where an
* object's lifetime is tied to the lifetime of a connection (or some other
* sequence of asynchronous operations), a @c shared_ptr to the object would
* be bound into the handlers for all asynchronous operations associated with
* it. This works as follows:
*
* @li When a single connection ends, all associated asynchronous operations
* complete. The corresponding handler objects are destroyed, and all
* @c shared_ptr references to the objects are destroyed.
*
* @li To shut down the whole program, the io_context function stop() is
* called to terminate any run() calls as soon as possible. The io_context
* destructor defined above destroys all handlers, causing all @c shared_ptr
* references to all connection objects to be destroyed.
*/
ASIO_DECL ~io_context();
/// Obtains the executor associated with the io_context.
executor_type get_executor() ASIO_NOEXCEPT;
/// Run the io_context object's event processing loop.
/**
* The run() function blocks until all work has finished and there are no
* more handlers to be dispatched, or until the io_context has been stopped.
*
* Multiple threads may call the run() function to set up a pool of threads
* from which the io_context may execute handlers. All threads that are
* waiting in the pool are equivalent and the io_context may choose any one
* of them to invoke a handler.
*
* A normal exit from the run() function implies that the io_context object
* is stopped (the stopped() function returns @c true). Subsequent calls to
* run(), run_one(), poll() or poll_one() will return immediately unless there
* is a prior call to restart().
*
* @return The number of handlers that were executed.
*
* @throws asio::system_error Thrown on failure.
*
* @note The run() function must not be called from a thread that is currently
* calling one of run(), run_one(), poll() or poll_one() on the same
* io_context object.
*
* The poll() function may also be used to dispatch ready handlers, but
* without blocking.
*/
ASIO_DECL std::size_t run();
/// Run the io_context object's event processing loop.
/**
* The run() function blocks until all work has finished and there are no
* more handlers to be dispatched, or until the io_context has been stopped.
*
* Multiple threads may call the run() function to set up a pool of threads
* from which the io_context may execute handlers. All threads that are
* waiting in the pool are equivalent and the io_context may choose any one
* of them to invoke a handler.
*
* A normal exit from the run() function implies that the io_context object
* is stopped (the stopped() function returns @c true). Subsequent calls to
* run(), run_one(), poll() or poll_one() will return immediately unless there
* is a prior call to restart().
*
* @param ec Set to indicate what error occurred, if any.
*
* @return The number of handlers that were executed.
*
* @note The run() function must not be called from a thread that is currently
* calling one of run(), run_one(), poll() or poll_one() on the same
* io_context object.
*
* The poll() function may also be used to dispatch ready handlers, but
* without blocking.
*/
ASIO_DECL std::size_t run(asio::error_code& ec);
/// Run the io_context object's event processing loop to execute at most one
/// handler.
/**
* The run_one() function blocks until one handler has been dispatched, or
* until the io_context has been stopped.
*
* @return The number of handlers that were executed. A zero return value
* implies that the io_context object is stopped (the stopped() function
* returns @c true). Subsequent calls to run(), run_one(), poll() or
* poll_one() will return immediately unless there is a prior call to
* restart().
*
* @throws asio::system_error Thrown on failure.
*/
ASIO_DECL std::size_t run_one();
/// Run the io_context object's event processing loop to execute at most one
/// handler.
/**
* The run_one() function blocks until one handler has been dispatched, or
* until the io_context has been stopped.
*
* @return The number of handlers that were executed. A zero return value
* implies that the io_context object is stopped (the stopped() function
* returns @c true). Subsequent calls to run(), run_one(), poll() or
* poll_one() will return immediately unless there is a prior call to
* restart().
*
* @return The number of handlers that were executed.
*/
ASIO_DECL std::size_t run_one(asio::error_code& ec);
/// Run the io_context object's event processing loop to execute ready
/// handlers.
/**
* The poll() function runs handlers that are ready to run, without blocking,
* until the io_context has been stopped or there are no more ready handlers.
*
* @return The number of handlers that were executed.
*
* @throws asio::system_error Thrown on failure.
*/
ASIO_DECL std::size_t poll();
/// Run the io_context object's event processing loop to execute ready
/// handlers.
/**
* The poll() function runs handlers that are ready to run, without blocking,
* until the io_context has been stopped or there are no more ready handlers.
*
* @param ec Set to indicate what error occurred, if any.
*
* @return The number of handlers that were executed.
*/
ASIO_DECL std::size_t poll(asio::error_code& ec);
/// Run the io_context object's event processing loop to execute one ready
/// handler.
/**
* The poll_one() function runs at most one handler that is ready to run,
* without blocking.
*
* @return The number of handlers that were executed.
*
* @throws asio::system_error Thrown on failure.
*/
ASIO_DECL std::size_t poll_one();
/// Run the io_context object's event processing loop to execute one ready
/// handler.
/**
* The poll_one() function runs at most one handler that is ready to run,
* without blocking.
*
* @param ec Set to indicate what error occurred, if any.
*
* @return The number of handlers that were executed.
*/
ASIO_DECL std::size_t poll_one(asio::error_code& ec);
/// Stop the io_context object's event processing loop.
/**
* This function does not block, but instead simply signals the io_context to
* stop. All invocations of its run() or run_one() member functions should
* return as soon as possible. Subsequent calls to run(), run_one(), poll()
* or poll_one() will return immediately until restart() is called.
*/
ASIO_DECL void stop();
/// Determine whether the io_context object has been stopped.
/**
* This function is used to determine whether an io_context object has been
* stopped, either through an explicit call to stop(), or due to running out
* of work. When an io_context object is stopped, calls to run(), run_one(),
* poll() or poll_one() will return immediately without invoking any
* handlers.
*
* @return @c true if the io_context object is stopped, otherwise @c false.
*/
ASIO_DECL bool stopped() const;
/// Restart the io_context in preparation for a subsequent run() invocation.
/**
* This function must be called prior to any second or later set of
* invocations of the run(), run_one(), poll() or poll_one() functions when a
* previous invocation of these functions returned due to the io_context
* being stopped or running out of work. After a call to restart(), the
* io_context object's stopped() function will return @c false.
*
* This function must not be called while there are any unfinished calls to
* the run(), run_one(), poll() or poll_one() functions.
*/
ASIO_DECL void restart();
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use restart().) Reset the io_context in preparation for a
/// subsequent run() invocation.
/**
* This function must be called prior to any second or later set of
* invocations of the run(), run_one(), poll() or poll_one() functions when a
* previous invocation of these functions returned due to the io_context
* being stopped or running out of work. After a call to restart(), the
* io_context object's stopped() function will return @c false.
*
* This function must not be called while there are any unfinished calls to
* the run(), run_one(), poll() or poll_one() functions.
*/
void reset();
/// (Deprecated: Use asio::dispatch().) Request the io_context to
/// invoke the given handler.
/**
* This function is used to ask the io_context to execute the given handler.
*
* The io_context guarantees that the handler will only be called in a thread
* in which the run(), run_one(), poll() or poll_one() member functions is
* currently being invoked. The handler may be executed inside this function
* if the guarantee can be met.
*
* @param handler The handler to be called. The io_context will make
* a copy of the handler object as required. The function signature of the
* handler must be: @code void handler(); @endcode
*
* @note This function throws an exception only if:
*
* @li the handler's @c asio_handler_allocate function; or
*
* @li the handler's copy constructor
*
* throws an exception.
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
dispatch(ASIO_MOVE_ARG(CompletionHandler) handler);
/// (Deprecated: Use asio::post().) Request the io_context to invoke
/// the given handler and return immediately.
/**
* This function is used to ask the io_context to execute the given handler,
* but without allowing the io_context to call the handler from inside this
* function.
*
* The io_context guarantees that the handler will only be called in a thread
* in which the run(), run_one(), poll() or poll_one() member functions is
* currently being invoked.
*
* @param handler The handler to be called. The io_context will make
* a copy of the handler object as required. The function signature of the
* handler must be: @code void handler(); @endcode
*
* @note This function throws an exception only if:
*
* @li the handler's @c asio_handler_allocate function; or
*
* @li the handler's copy constructor
*
* throws an exception.
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
post(ASIO_MOVE_ARG(CompletionHandler) handler);
/// (Deprecated: Use asio::bind_executor().) Create a new handler that
/// automatically dispatches the wrapped handler on the io_context.
/**
* This function is used to create a new handler function object that, when
* invoked, will automatically pass the wrapped handler to the io_context
* object's dispatch function.
*
* @param handler The handler to be wrapped. The io_context will make a copy
* of the handler object as required. The function signature of the handler
* must be: @code void handler(A1 a1, ... An an); @endcode
*
* @return A function object that, when invoked, passes the wrapped handler to
* the io_context object's dispatch function. Given a function object with the
* signature:
* @code R f(A1 a1, ... An an); @endcode
* If this function object is passed to the wrap function like so:
* @code io_context.wrap(f); @endcode
* then the return value is a function object with the signature
* @code void g(A1 a1, ... An an); @endcode
* that, when invoked, executes code equivalent to:
* @code io_context.dispatch(boost::bind(f, a1, ... an)); @endcode
*/
template <typename Handler>
#if defined(GENERATING_DOCUMENTATION)
unspecified
#else
detail::wrapped_handler<io_context&, Handler>
#endif
wrap(Handler handler);
#endif // !defined(ASIO_NO_DEPRECATED)
private:
// Helper function to create the implementation.
ASIO_DECL impl_type& create_impl(std::size_t concurrency_hint = 0);
// Backwards compatible overload for use with services derived from
// io_context::service.
template <typename Service>
friend Service& use_service(io_context& ioc);
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
detail::winsock_init<> init_;
#elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
|| defined(__osf__)
detail::signal_init<> init_;
#endif
// The implementation.
impl_type& impl_;
};
/// Executor used to submit functions to an io_context.
class io_context::executor_type
{
public:
/// Obtain the underlying execution context.
io_context& context() ASIO_NOEXCEPT;
/// Inform the io_context that it has some outstanding work to do.
/**
* This function is used to inform the io_context that some work has begun.
* This ensures that the io_context's run() and run_one() functions do not
* exit while the work is underway.
*/
void on_work_started() ASIO_NOEXCEPT;
/// Inform the io_context that some work is no longer outstanding.
/**
* This function is used to inform the io_context that some work has
* finished. Once the count of unfinished work reaches zero, the io_context
* is stopped and the run() and run_one() functions may exit.
*/
void on_work_finished() ASIO_NOEXCEPT;
/// Request the io_context to invoke the given function object.
/**
* This function is used to ask the io_context to execute the given function
* object. If the current thread is running the io_context, @c dispatch()
* executes the function before returning. Otherwise, the function will be
* scheduled to run on the io_context.
*
* @param f The function object to be called. The executor will make a copy
* of the handler object as required. The function signature of the function
* object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator& a);
/// Request the io_context to invoke the given function object.
/**
* This function is used to ask the io_context to execute the given function
* object. The function object will never be executed inside @c post().
* Instead, it will be scheduled to run on the io_context.
*
* @param f The function object to be called. The executor will make a copy
* of the handler object as required. The function signature of the function
* object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void post(ASIO_MOVE_ARG(Function) f, const Allocator& a);
/// Request the io_context to invoke the given function object.
/**
* This function is used to ask the io_context to execute the given function
* object. The function object will never be executed inside @c defer().
* Instead, it will be scheduled to run on the io_context.
*
* If the current thread belongs to the io_context, @c defer() will delay
* scheduling the function object until the current thread returns control to
* the pool.
*
* @param f The function object to be called. The executor will make a copy
* of the handler object as required. The function signature of the function
* object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void defer(ASIO_MOVE_ARG(Function) f, const Allocator& a);
/// Determine whether the io_context is running in the current thread.
/**
* @return @c true if the current thread is running the io_context. Otherwise
* returns @c false.
*/
bool running_in_this_thread() const ASIO_NOEXCEPT;
/// Compare two executors for equality.
/**
* Two executors are equal if they refer to the same underlying io_context.
*/
friend bool operator==(const executor_type& a,
const executor_type& b) ASIO_NOEXCEPT
{
return &a.io_context_ == &b.io_context_;
}
/// Compare two executors for inequality.
/**
* Two executors are equal if they refer to the same underlying io_context.
*/
friend bool operator!=(const executor_type& a,
const executor_type& b) ASIO_NOEXCEPT
{
return &a.io_context_ != &b.io_context_;
}
private:
friend class io_context;
// Constructor.
explicit executor_type(io_context& i) : io_context_(i) {}
// The underlying io_context.
io_context& io_context_;
};
#if !defined(GENERATING_DOCUMENTATION)
template <> struct is_executor<io_context::executor_type> : true_type {};
#endif // !defined(GENERATING_DOCUMENTATION)
/// (Deprecated: Use executor_work_guard.) Class to inform the io_context when
/// it has work to do.
/**
* The work class is used to inform the io_context when work starts and
* finishes. This ensures that the io_context object's run() function will not
* exit while work is underway, and that it does exit when there is no
* unfinished work remaining.
*
* The work class is copy-constructible so that it may be used as a data member
* in a handler class. It is not assignable.
*/
class io_context::work
{
public:
/// Constructor notifies the io_context that work is starting.
/**
* The constructor is used to inform the io_context that some work has begun.
* This ensures that the io_context object's run() function will not exit
* while the work is underway.
*/
explicit work(asio::io_context& io_context);
/// Copy constructor notifies the io_context that work is starting.
/**
* The constructor is used to inform the io_context that some work has begun.
* This ensures that the io_context object's run() function will not exit
* while the work is underway.
*/
work(const work& other);
/// Destructor notifies the io_context that the work is complete.
/**
* The destructor is used to inform the io_context that some work has
* finished. Once the count of unfinished work reaches zero, the io_context
* object's run() function is permitted to exit.
*/
~work();
/// Get the io_context associated with the work.
asio::io_context& get_io_context();
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use get_io_context().) Get the io_context associated with the
/// work.
asio::io_context& get_io_service();
#endif // !defined(ASIO_NO_DEPRECATED)
private:
// Prevent assignment.
void operator=(const work& other);
// The io_context implementation.
detail::io_context_impl& io_context_impl_;
};
/// Base class for all io_context services.
class io_context::service
: public execution_context::service
{
public:
/// Get the io_context object that owns the service.
asio::io_context& get_io_context();
#if !defined(ASIO_NO_DEPRECATED)
/// Get the io_context object that owns the service.
asio::io_context& get_io_service();
#endif // !defined(ASIO_NO_DEPRECATED)
protected:
/// Constructor.
/**
* @param owner The io_context object that owns the service.
*/
ASIO_DECL service(asio::io_context& owner);
/// Destructor.
ASIO_DECL virtual ~service();
};
namespace detail {
// Special service base class to keep classes header-file only.
template <typename Type>
class service_base
: public asio::io_context::service
{
public:
static asio::detail::service_id<Type> id;
// Constructor.
service_base(asio::io_context& io_context)
: asio::io_context::service(io_context)
{
}
};
template <typename Type>
asio::detail::service_id<Type> service_base<Type>::id;
} // namespace detail
} // namespace asio
#include "asio/detail/pop_options.hpp"
#include "asio/impl/io_context.hpp"
#if defined(ASIO_HEADER_ONLY)
# include "asio/impl/io_context.ipp"
#endif // defined(ASIO_HEADER_ONLY)
// If both io_context.hpp and strand.hpp have been included, automatically
// include the header file needed for the io_context::strand class.
#if defined(ASIO_STRAND_HPP)
# include "asio/io_context_strand.hpp"
#endif // defined(ASIO_STRAND_HPP)
#endif // ASIO_IO_CONTEXT_HPP

View File

@ -0,0 +1,382 @@
//
// io_context_strand.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 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)
//
#ifndef ASIO_IO_CONTEXT_STRAND_HPP
#define ASIO_IO_CONTEXT_STRAND_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include "asio/async_result.hpp"
#include "asio/detail/handler_type_requirements.hpp"
#include "asio/detail/strand_service.hpp"
#include "asio/detail/wrapped_handler.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
/// Provides serialised handler execution.
/**
* The io_context::strand class provides the ability to post and dispatch
* handlers with the guarantee that none of those handlers will execute
* concurrently.
*
* @par Order of handler invocation
* Given:
*
* @li a strand object @c s
*
* @li an object @c a meeting completion handler requirements
*
* @li an object @c a1 which is an arbitrary copy of @c a made by the
* implementation
*
* @li an object @c b meeting completion handler requirements
*
* @li an object @c b1 which is an arbitrary copy of @c b made by the
* implementation
*
* if any of the following conditions are true:
*
* @li @c s.post(a) happens-before @c s.post(b)
*
* @li @c s.post(a) happens-before @c s.dispatch(b), where the latter is
* performed outside the strand
*
* @li @c s.dispatch(a) happens-before @c s.post(b), where the former is
* performed outside the strand
*
* @li @c s.dispatch(a) happens-before @c s.dispatch(b), where both are
* performed outside the strand
*
* then @c asio_handler_invoke(a1, &a1) happens-before
* @c asio_handler_invoke(b1, &b1).
*
* Note that in the following case:
* @code async_op_1(..., s.wrap(a));
* async_op_2(..., s.wrap(b)); @endcode
* the completion of the first async operation will perform @c s.dispatch(a),
* and the second will perform @c s.dispatch(b), but the order in which those
* are performed is unspecified. That is, you cannot state whether one
* happens-before the other. Therefore none of the above conditions are met and
* no ordering guarantee is made.
*
* @note The implementation makes no guarantee that handlers posted or
* dispatched through different @c strand objects will be invoked concurrently.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Safe.
*
* @par Concepts:
* Dispatcher.
*/
class io_context::strand
{
public:
/// Constructor.
/**
* Constructs the strand.
*
* @param io_context The io_context object that the strand will use to
* dispatch handlers that are ready to be run.
*/
explicit strand(asio::io_context& io_context)
: service_(asio::use_service<
asio::detail::strand_service>(io_context))
{
service_.construct(impl_);
}
/// Destructor.
/**
* Destroys a strand.
*
* Handlers posted through the strand that have not yet been invoked will
* still be dispatched in a way that meets the guarantee of non-concurrency.
*/
~strand()
{
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use context().) Get the io_context associated with the
/// strand.
/**
* This function may be used to obtain the io_context object that the strand
* uses to dispatch handlers for asynchronous operations.
*
* @return A reference to the io_context object that the strand will use to
* dispatch handlers. Ownership is not transferred to the caller.
*/
asio::io_context& get_io_context()
{
return service_.get_io_context();
}
/// (Deprecated: Use context().) Get the io_context associated with the
/// strand.
/**
* This function may be used to obtain the io_context object that the strand
* uses to dispatch handlers for asynchronous operations.
*
* @return A reference to the io_context object that the strand will use to
* dispatch handlers. Ownership is not transferred to the caller.
*/
asio::io_context& get_io_service()
{
return service_.get_io_context();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Obtain the underlying execution context.
asio::io_context& context() ASIO_NOEXCEPT
{
return service_.get_io_context();
}
/// Inform the strand that it has some outstanding work to do.
/**
* The strand delegates this call to its underlying io_context.
*/
void on_work_started() ASIO_NOEXCEPT
{
context().get_executor().on_work_started();
}
/// Inform the strand that some work is no longer outstanding.
/**
* The strand delegates this call to its underlying io_context.
*/
void on_work_finished() ASIO_NOEXCEPT
{
context().get_executor().on_work_finished();
}
/// Request the strand to invoke the given function object.
/**
* This function is used to ask the strand to execute the given function
* object on its underlying io_context. The function object will be executed
* inside this function if the strand is not otherwise busy and if the
* underlying io_context's executor's @c dispatch() function is also able to
* execute the function before returning.
*
* @param f The function object to be called. The executor will make
* a copy of the handler object as required. The function signature of the
* function object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
service_.dispatch(impl_, tmp);
(void)a;
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use asio::dispatch().) Request the strand to invoke
/// the given handler.
/**
* This function is used to ask the strand to execute the given handler.
*
* The strand object guarantees that handlers posted or dispatched through
* the strand will not be executed concurrently. The handler may be executed
* inside this function if the guarantee can be met. If this function is
* called from within a handler that was posted or dispatched through the same
* strand, then the new handler will be executed immediately.
*
* The strand's guarantee is in addition to the guarantee provided by the
* underlying io_context. The io_context guarantees that the handler will only
* be called in a thread in which the io_context's run member function is
* currently being invoked.
*
* @param handler The handler to be called. The strand will make a copy of the
* handler object as required. The function signature of the handler must be:
* @code void handler(); @endcode
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
async_completion<CompletionHandler, void ()> init(handler);
service_.dispatch(impl_, init.handler);
return init.result.get();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Request the strand to invoke the given function object.
/**
* This function is used to ask the executor to execute the given function
* object. The function object will never be executed inside this function.
* Instead, it will be scheduled to run by the underlying io_context.
*
* @param f The function object to be called. The executor will make
* a copy of the handler object as required. The function signature of the
* function object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void post(ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
service_.post(impl_, tmp);
(void)a;
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use asio::post().) Request the strand to invoke the
/// given handler and return immediately.
/**
* This function is used to ask the strand to execute the given handler, but
* without allowing the strand to call the handler from inside this function.
*
* The strand object guarantees that handlers posted or dispatched through
* the strand will not be executed concurrently. The strand's guarantee is in
* addition to the guarantee provided by the underlying io_context. The
* io_context guarantees that the handler will only be called in a thread in
* which the io_context's run member function is currently being invoked.
*
* @param handler The handler to be called. The strand will make a copy of the
* handler object as required. The function signature of the handler must be:
* @code void handler(); @endcode
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
post(ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
async_completion<CompletionHandler, void ()> init(handler);
service_.post(impl_, init.handler);
return init.result.get();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Request the strand to invoke the given function object.
/**
* This function is used to ask the executor to execute the given function
* object. The function object will never be executed inside this function.
* Instead, it will be scheduled to run by the underlying io_context.
*
* @param f The function object to be called. The executor will make
* a copy of the handler object as required. The function signature of the
* function object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void defer(ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
service_.post(impl_, tmp);
(void)a;
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use asio::bind_executor().) Create a new handler that
/// automatically dispatches the wrapped handler on the strand.
/**
* This function is used to create a new handler function object that, when
* invoked, will automatically pass the wrapped handler to the strand's
* dispatch function.
*
* @param handler The handler to be wrapped. The strand will make a copy of
* the handler object as required. The function signature of the handler must
* be: @code void handler(A1 a1, ... An an); @endcode
*
* @return A function object that, when invoked, passes the wrapped handler to
* the strand's dispatch function. Given a function object with the signature:
* @code R f(A1 a1, ... An an); @endcode
* If this function object is passed to the wrap function like so:
* @code strand.wrap(f); @endcode
* then the return value is a function object with the signature
* @code void g(A1 a1, ... An an); @endcode
* that, when invoked, executes code equivalent to:
* @code strand.dispatch(boost::bind(f, a1, ... an)); @endcode
*/
template <typename Handler>
#if defined(GENERATING_DOCUMENTATION)
unspecified
#else
detail::wrapped_handler<strand, Handler, detail::is_continuation_if_running>
#endif
wrap(Handler handler)
{
return detail::wrapped_handler<io_context::strand, Handler,
detail::is_continuation_if_running>(*this, handler);
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Determine whether the strand is running in the current thread.
/**
* @return @c true if the current thread is executing a handler that was
* submitted to the strand using post(), dispatch() or wrap(). Otherwise
* returns @c false.
*/
bool running_in_this_thread() const ASIO_NOEXCEPT
{
return service_.running_in_this_thread(impl_);
}
/// Compare two strands for equality.
/**
* Two strands are equal if they refer to the same ordered, non-concurrent
* state.
*/
friend bool operator==(const strand& a, const strand& b) ASIO_NOEXCEPT
{
return a.impl_ == b.impl_;
}
/// Compare two strands for inequality.
/**
* Two strands are equal if they refer to the same ordered, non-concurrent
* state.
*/
friend bool operator!=(const strand& a, const strand& b) ASIO_NOEXCEPT
{
return a.impl_ != b.impl_;
}
private:
asio::detail::strand_service& service_;
asio::detail::strand_service::implementation_type impl_;
};
#if !defined(GENERATING_DOCUMENTATION)
template <>
struct is_executor<io_context::strand> : true_type {};
#endif // !defined(GENERATING_DOCUMENTATION)
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // ASIO_IO_CONTEXT_STRAND_HPP

View File

@ -15,709 +15,17 @@
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include <cstddef>
#include <stdexcept>
#include <typeinfo>
#include "asio/async_result.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/wrapped_handler.hpp"
#include "asio/error_code.hpp"
#include "asio/execution_context.hpp"
#include "asio/is_executor.hpp"
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
# include "asio/detail/winsock_init.hpp"
#elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
|| defined(__osf__)
# include "asio/detail/signal_init.hpp"
#endif
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
namespace detail {
#if defined(ASIO_HAS_IOCP)
typedef class win_iocp_io_service io_service_impl;
class win_iocp_overlapped_ptr;
#else
typedef class scheduler io_service_impl;
#endif
} // namespace detail
/// Typedef for backwards compatibility.
typedef io_context io_service;
/// Provides core I/O functionality.
/**
* The io_service class provides the core I/O functionality for users of the
* asynchronous I/O objects, including:
*
* @li asio::ip::tcp::socket
* @li asio::ip::tcp::acceptor
* @li asio::ip::udp::socket
* @li asio::deadline_timer.
*
* The io_service class also includes facilities intended for developers of
* custom asynchronous services.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Safe, with the specific exceptions of the restart() and
* notify_fork() functions. Calling restart() while there are unfinished run(),
* run_one(), poll() or poll_one() calls results in undefined behaviour. The
* notify_fork() function should not be called while any io_service function,
* or any function on an I/O object that is associated with the io_service, is
* being called in another thread.
*
* @par Concepts:
* Dispatcher.
*
* @par Synchronous and asynchronous operations
*
* Synchronous operations on I/O objects implicitly run the io_service object
* for an individual operation. The io_service functions run(), run_one(),
* poll() or poll_one() must be called for the io_service to perform
* asynchronous operations on behalf of a C++ program. Notification that an
* asynchronous operation has completed is delivered by invocation of the
* associated handler. Handlers are invoked only by a thread that is currently
* calling any overload of run(), run_one(), poll() or poll_one() for the
* io_service.
*
* @par Effect of exceptions thrown from handlers
*
* If an exception is thrown from a handler, the exception is allowed to
* propagate through the throwing thread's invocation of run(), run_one(),
* poll() or poll_one(). No other threads that are calling any of these
* functions are affected. It is then the responsibility of the application to
* catch the exception.
*
* After the exception has been caught, the run(), run_one(), poll() or
* poll_one() call may be restarted @em without the need for an intervening
* call to restart(). This allows the thread to rejoin the io_service object's
* thread pool without impacting any other threads in the pool.
*
* For example:
*
* @code
* asio::io_service io_service;
* ...
* for (;;)
* {
* try
* {
* io_service.run();
* break; // run() exited normally
* }
* catch (my_exception& e)
* {
* // Deal with exception as appropriate.
* }
* }
* @endcode
*
* @par Stopping the io_service from running out of work
*
* Some applications may need to prevent an io_service object's run() call from
* returning when there is no more work to do. For example, the io_service may
* be being run in a background thread that is launched prior to the
* application's asynchronous operations. The run() call may be kept running by
* creating an object of type asio::io_service::work:
*
* @code asio::io_service io_service;
* asio::io_service::work work(io_service);
* ... @endcode
*
* To effect a shutdown, the application will then need to call the io_service
* object's stop() member function. This will cause the io_service run() call
* to return as soon as possible, abandoning unfinished operations and without
* permitting ready handlers to be dispatched.
*
* Alternatively, if the application requires that all operations and handlers
* be allowed to finish normally, the work object may be explicitly destroyed.
*
* @code asio::io_service io_service;
* auto_ptr<asio::io_service::work> work(
* new asio::io_service::work(io_service));
* ...
* work.reset(); // Allow run() to exit. @endcode
*/
class io_service
: public execution_context
{
private:
typedef detail::io_service_impl impl_type;
#if defined(ASIO_HAS_IOCP)
friend class detail::win_iocp_overlapped_ptr;
#endif
public:
class executor_type;
friend class executor_type;
class work;
friend class work;
class service;
class strand;
/// Constructor.
ASIO_DECL io_service();
/// Constructor.
/**
* Construct with a hint about the required level of concurrency.
*
* @param concurrency_hint A suggestion to the implementation on how many
* threads it should allow to run simultaneously.
*/
ASIO_DECL explicit io_service(std::size_t concurrency_hint);
/// Destructor.
/**
* On destruction, the io_service performs the following sequence of
* operations:
*
* @li For each service object @c svc in the io_service set, in reverse order
* of the beginning of service object lifetime, performs
* @c svc->shutdown_service().
*
* @li Uninvoked handler objects that were scheduled for deferred invocation
* on the io_service, or any associated strand, are destroyed.
*
* @li For each service object @c svc in the io_service set, in reverse order
* of the beginning of service object lifetime, performs
* <tt>delete static_cast<io_service::service*>(svc)</tt>.
*
* @note The destruction sequence described above permits programs to
* simplify their resource management by using @c shared_ptr<>. Where an
* object's lifetime is tied to the lifetime of a connection (or some other
* sequence of asynchronous operations), a @c shared_ptr to the object would
* be bound into the handlers for all asynchronous operations associated with
* it. This works as follows:
*
* @li When a single connection ends, all associated asynchronous operations
* complete. The corresponding handler objects are destroyed, and all
* @c shared_ptr references to the objects are destroyed.
*
* @li To shut down the whole program, the io_service function stop() is
* called to terminate any run() calls as soon as possible. The io_service
* destructor defined above destroys all handlers, causing all @c shared_ptr
* references to all connection objects to be destroyed.
*/
ASIO_DECL ~io_service();
/// Obtains the executor associated with the io_service.
executor_type get_executor() ASIO_NOEXCEPT;
/// Run the io_service object's event processing loop.
/**
* The run() function blocks until all work has finished and there are no
* more handlers to be dispatched, or until the io_service has been stopped.
*
* Multiple threads may call the run() function to set up a pool of threads
* from which the io_service may execute handlers. All threads that are
* waiting in the pool are equivalent and the io_service may choose any one
* of them to invoke a handler.
*
* A normal exit from the run() function implies that the io_service object
* is stopped (the stopped() function returns @c true). Subsequent calls to
* run(), run_one(), poll() or poll_one() will return immediately unless there
* is a prior call to restart().
*
* @return The number of handlers that were executed.
*
* @throws asio::system_error Thrown on failure.
*
* @note The run() function must not be called from a thread that is currently
* calling one of run(), run_one(), poll() or poll_one() on the same
* io_service object.
*
* The poll() function may also be used to dispatch ready handlers, but
* without blocking.
*/
ASIO_DECL std::size_t run();
/// Run the io_service object's event processing loop.
/**
* The run() function blocks until all work has finished and there are no
* more handlers to be dispatched, or until the io_service has been stopped.
*
* Multiple threads may call the run() function to set up a pool of threads
* from which the io_service may execute handlers. All threads that are
* waiting in the pool are equivalent and the io_service may choose any one
* of them to invoke a handler.
*
* A normal exit from the run() function implies that the io_service object
* is stopped (the stopped() function returns @c true). Subsequent calls to
* run(), run_one(), poll() or poll_one() will return immediately unless there
* is a prior call to restart().
*
* @param ec Set to indicate what error occurred, if any.
*
* @return The number of handlers that were executed.
*
* @note The run() function must not be called from a thread that is currently
* calling one of run(), run_one(), poll() or poll_one() on the same
* io_service object.
*
* The poll() function may also be used to dispatch ready handlers, but
* without blocking.
*/
ASIO_DECL std::size_t run(asio::error_code& ec);
/// Run the io_service object's event processing loop to execute at most one
/// handler.
/**
* The run_one() function blocks until one handler has been dispatched, or
* until the io_service has been stopped.
*
* @return The number of handlers that were executed. A zero return value
* implies that the io_service object is stopped (the stopped() function
* returns @c true). Subsequent calls to run(), run_one(), poll() or
* poll_one() will return immediately unless there is a prior call to
* restart().
*
* @throws asio::system_error Thrown on failure.
*/
ASIO_DECL std::size_t run_one();
/// Run the io_service object's event processing loop to execute at most one
/// handler.
/**
* The run_one() function blocks until one handler has been dispatched, or
* until the io_service has been stopped.
*
* @return The number of handlers that were executed. A zero return value
* implies that the io_service object is stopped (the stopped() function
* returns @c true). Subsequent calls to run(), run_one(), poll() or
* poll_one() will return immediately unless there is a prior call to
* restart().
*
* @return The number of handlers that were executed.
*/
ASIO_DECL std::size_t run_one(asio::error_code& ec);
/// Run the io_service object's event processing loop to execute ready
/// handlers.
/**
* The poll() function runs handlers that are ready to run, without blocking,
* until the io_service has been stopped or there are no more ready handlers.
*
* @return The number of handlers that were executed.
*
* @throws asio::system_error Thrown on failure.
*/
ASIO_DECL std::size_t poll();
/// Run the io_service object's event processing loop to execute ready
/// handlers.
/**
* The poll() function runs handlers that are ready to run, without blocking,
* until the io_service has been stopped or there are no more ready handlers.
*
* @param ec Set to indicate what error occurred, if any.
*
* @return The number of handlers that were executed.
*/
ASIO_DECL std::size_t poll(asio::error_code& ec);
/// Run the io_service object's event processing loop to execute one ready
/// handler.
/**
* The poll_one() function runs at most one handler that is ready to run,
* without blocking.
*
* @return The number of handlers that were executed.
*
* @throws asio::system_error Thrown on failure.
*/
ASIO_DECL std::size_t poll_one();
/// Run the io_service object's event processing loop to execute one ready
/// handler.
/**
* The poll_one() function runs at most one handler that is ready to run,
* without blocking.
*
* @param ec Set to indicate what error occurred, if any.
*
* @return The number of handlers that were executed.
*/
ASIO_DECL std::size_t poll_one(asio::error_code& ec);
/// Stop the io_service object's event processing loop.
/**
* This function does not block, but instead simply signals the io_service to
* stop. All invocations of its run() or run_one() member functions should
* return as soon as possible. Subsequent calls to run(), run_one(), poll()
* or poll_one() will return immediately until restart() is called.
*/
ASIO_DECL void stop();
/// Determine whether the io_service object has been stopped.
/**
* This function is used to determine whether an io_service object has been
* stopped, either through an explicit call to stop(), or due to running out
* of work. When an io_service object is stopped, calls to run(), run_one(),
* poll() or poll_one() will return immediately without invoking any
* handlers.
*
* @return @c true if the io_service object is stopped, otherwise @c false.
*/
ASIO_DECL bool stopped() const;
/// Restart the io_service in preparation for a subsequent run() invocation.
/**
* This function must be called prior to any second or later set of
* invocations of the run(), run_one(), poll() or poll_one() functions when a
* previous invocation of these functions returned due to the io_service
* being stopped or running out of work. After a call to restart(), the
* io_service object's stopped() function will return @c false.
*
* This function must not be called while there are any unfinished calls to
* the run(), run_one(), poll() or poll_one() functions.
*/
ASIO_DECL void restart();
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use restart().) Reset the io_service in preparation for a
/// subsequent run() invocation.
/**
* This function must be called prior to any second or later set of
* invocations of the run(), run_one(), poll() or poll_one() functions when a
* previous invocation of these functions returned due to the io_service
* being stopped or running out of work. After a call to restart(), the
* io_service object's stopped() function will return @c false.
*
* This function must not be called while there are any unfinished calls to
* the run(), run_one(), poll() or poll_one() functions.
*/
void reset();
/// (Deprecated: Use asio::dispatch().) Request the io_service to
/// invoke the given handler.
/**
* This function is used to ask the io_service to execute the given handler.
*
* The io_service guarantees that the handler will only be called in a thread
* in which the run(), run_one(), poll() or poll_one() member functions is
* currently being invoked. The handler may be executed inside this function
* if the guarantee can be met.
*
* @param handler The handler to be called. The io_service will make
* a copy of the handler object as required. The function signature of the
* handler must be: @code void handler(); @endcode
*
* @note This function throws an exception only if:
*
* @li the handler's @c asio_handler_allocate function; or
*
* @li the handler's copy constructor
*
* throws an exception.
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
dispatch(ASIO_MOVE_ARG(CompletionHandler) handler);
/// (Deprecated: Use asio::post().) Request the io_service to invoke
/// the given handler and return immediately.
/**
* This function is used to ask the io_service to execute the given handler,
* but without allowing the io_service to call the handler from inside this
* function.
*
* The io_service guarantees that the handler will only be called in a thread
* in which the run(), run_one(), poll() or poll_one() member functions is
* currently being invoked.
*
* @param handler The handler to be called. The io_service will make
* a copy of the handler object as required. The function signature of the
* handler must be: @code void handler(); @endcode
*
* @note This function throws an exception only if:
*
* @li the handler's @c asio_handler_allocate function; or
*
* @li the handler's copy constructor
*
* throws an exception.
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
post(ASIO_MOVE_ARG(CompletionHandler) handler);
/// (Deprecated: Use asio::bind_executor().) Create a new handler that
/// automatically dispatches the wrapped handler on the io_service.
/**
* This function is used to create a new handler function object that, when
* invoked, will automatically pass the wrapped handler to the io_service
* object's dispatch function.
*
* @param handler The handler to be wrapped. The io_service will make a copy
* of the handler object as required. The function signature of the handler
* must be: @code void handler(A1 a1, ... An an); @endcode
*
* @return A function object that, when invoked, passes the wrapped handler to
* the io_service object's dispatch function. Given a function object with the
* signature:
* @code R f(A1 a1, ... An an); @endcode
* If this function object is passed to the wrap function like so:
* @code io_service.wrap(f); @endcode
* then the return value is a function object with the signature
* @code void g(A1 a1, ... An an); @endcode
* that, when invoked, executes code equivalent to:
* @code io_service.dispatch(boost::bind(f, a1, ... an)); @endcode
*/
template <typename Handler>
#if defined(GENERATING_DOCUMENTATION)
unspecified
#else
detail::wrapped_handler<io_service&, Handler>
#endif
wrap(Handler handler);
#endif // !defined(ASIO_NO_DEPRECATED)
private:
// Helper function to create the implementation.
ASIO_DECL impl_type& create_impl(std::size_t concurrency_hint = 0);
// Backwards compatible overload for use with services derived from
// io_service::service.
template <typename Service>
friend Service& use_service(io_service& ios);
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
detail::winsock_init<> init_;
#elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
|| defined(__osf__)
detail::signal_init<> init_;
#endif
// The implementation.
impl_type& impl_;
};
/// Executor used to submit functions to an io_service.
class io_service::executor_type
{
public:
/// Obtain the underlying execution context.
io_service& context() ASIO_NOEXCEPT;
/// Inform the io_service that it has some outstanding work to do.
/**
* This function is used to inform the io_service that some work has begun.
* This ensures that the io_service's run() and run_one() functions do not
* exit while the work is underway.
*/
void on_work_started() ASIO_NOEXCEPT;
/// Inform the io_service that some work is no longer outstanding.
/**
* This function is used to inform the io_service that some work has
* finished. Once the count of unfinished work reaches zero, the io_service
* is stopped and the run() and run_one() functions may exit.
*/
void on_work_finished() ASIO_NOEXCEPT;
/// Request the io_service to invoke the given function object.
/**
* This function is used to ask the io_service to execute the given function
* object. If the current thread is running the io_service, @c dispatch()
* executes the function before returning. Otherwise, the function will be
* scheduled to run on the io_service.
*
* @param f The function object to be called. The executor will make a copy
* of the handler object as required. The function signature of the function
* object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator& a);
/// Request the io_service to invoke the given function object.
/**
* This function is used to ask the io_service to execute the given function
* object. The function object will never be executed inside @c post().
* Instead, it will be scheduled to run on the io_service.
*
* @param f The function object to be called. The executor will make a copy
* of the handler object as required. The function signature of the function
* object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void post(ASIO_MOVE_ARG(Function) f, const Allocator& a);
/// Request the io_service to invoke the given function object.
/**
* This function is used to ask the io_service to execute the given function
* object. The function object will never be executed inside @c defer().
* Instead, it will be scheduled to run on the io_service.
*
* If the current thread belongs to the io_service, @c defer() will delay
* scheduling the function object until the current thread returns control to
* the pool.
*
* @param f The function object to be called. The executor will make a copy
* of the handler object as required. The function signature of the function
* object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void defer(ASIO_MOVE_ARG(Function) f, const Allocator& a);
/// Determine whether the io_service is running in the current thread.
/**
* @return @c true if the current thread is running the io_service. Otherwise
* returns @c false.
*/
bool running_in_this_thread() const ASIO_NOEXCEPT;
/// Compare two executors for equality.
/**
* Two executors are equal if they refer to the same underlying io_service.
*/
friend bool operator==(const executor_type& a,
const executor_type& b) ASIO_NOEXCEPT
{
return &a.io_service_ == &b.io_service_;
}
/// Compare two executors for inequality.
/**
* Two executors are equal if they refer to the same underlying io_service.
*/
friend bool operator!=(const executor_type& a,
const executor_type& b) ASIO_NOEXCEPT
{
return &a.io_service_ != &b.io_service_;
}
private:
friend class io_service;
// Constructor.
explicit executor_type(io_service& i) : io_service_(i) {}
// The underlying io_service.
io_service& io_service_;
};
#if !defined(GENERATING_DOCUMENTATION)
template <> struct is_executor<io_service::executor_type> : true_type {};
#endif // !defined(GENERATING_DOCUMENTATION)
/// (Deprecated: Use executor_work_guard.) Class to inform the io_service when
/// it has work to do.
/**
* The work class is used to inform the io_service when work starts and
* finishes. This ensures that the io_service object's run() function will not
* exit while work is underway, and that it does exit when there is no
* unfinished work remaining.
*
* The work class is copy-constructible so that it may be used as a data member
* in a handler class. It is not assignable.
*/
class io_service::work
{
public:
/// Constructor notifies the io_service that work is starting.
/**
* The constructor is used to inform the io_service that some work has begun.
* This ensures that the io_service object's run() function will not exit
* while the work is underway.
*/
explicit work(asio::io_service& io_service);
/// Copy constructor notifies the io_service that work is starting.
/**
* The constructor is used to inform the io_service that some work has begun.
* This ensures that the io_service object's run() function will not exit
* while the work is underway.
*/
work(const work& other);
/// Destructor notifies the io_service that the work is complete.
/**
* The destructor is used to inform the io_service that some work has
* finished. Once the count of unfinished work reaches zero, the io_service
* object's run() function is permitted to exit.
*/
~work();
/// Get the io_service associated with the work.
asio::io_service& get_io_service();
private:
// Prevent assignment.
void operator=(const work& other);
// The io_service implementation.
detail::io_service_impl& io_service_impl_;
};
/// Base class for all io_service services.
class io_service::service
: public execution_context::service
{
public:
/// Get the io_service object that owns the service.
asio::io_service& get_io_service();
protected:
/// Constructor.
/**
* @param owner The io_service object that owns the service.
*/
ASIO_DECL service(asio::io_service& owner);
/// Destructor.
ASIO_DECL virtual ~service();
};
namespace detail {
// Special service base class to keep classes header-file only.
template <typename Type>
class service_base
: public asio::io_service::service
{
public:
static asio::detail::service_id<Type> id;
// Constructor.
service_base(asio::io_service& io_service)
: asio::io_service::service(io_service)
{
}
};
template <typename Type>
asio::detail::service_id<Type> service_base<Type>::id;
} // namespace detail
} // namespace asio
#include "asio/detail/pop_options.hpp"
#include "asio/impl/io_service.hpp"
#if defined(ASIO_HEADER_ONLY)
# include "asio/impl/io_service.ipp"
#endif // defined(ASIO_HEADER_ONLY)
// If both io_service.hpp and strand.hpp have been included, automatically
// include the header file needed for the io_service::strand class.
#if defined(ASIO_STRAND_HPP)
# include "asio/io_service_strand.hpp"
#endif // defined(ASIO_STRAND_HPP)
#endif // ASIO_IO_SERVICE_HPP

View File

@ -15,354 +15,6 @@
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include "asio/async_result.hpp"
#include "asio/detail/handler_type_requirements.hpp"
#include "asio/detail/strand_service.hpp"
#include "asio/detail/wrapped_handler.hpp"
#include "asio/io_service.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
/// Provides serialised handler execution.
/**
* The io_service::strand class provides the ability to post and dispatch
* handlers with the guarantee that none of those handlers will execute
* concurrently.
*
* @par Order of handler invocation
* Given:
*
* @li a strand object @c s
*
* @li an object @c a meeting completion handler requirements
*
* @li an object @c a1 which is an arbitrary copy of @c a made by the
* implementation
*
* @li an object @c b meeting completion handler requirements
*
* @li an object @c b1 which is an arbitrary copy of @c b made by the
* implementation
*
* if any of the following conditions are true:
*
* @li @c s.post(a) happens-before @c s.post(b)
*
* @li @c s.post(a) happens-before @c s.dispatch(b), where the latter is
* performed outside the strand
*
* @li @c s.dispatch(a) happens-before @c s.post(b), where the former is
* performed outside the strand
*
* @li @c s.dispatch(a) happens-before @c s.dispatch(b), where both are
* performed outside the strand
*
* then @c asio_handler_invoke(a1, &a1) happens-before
* @c asio_handler_invoke(b1, &b1).
*
* Note that in the following case:
* @code async_op_1(..., s.wrap(a));
* async_op_2(..., s.wrap(b)); @endcode
* the completion of the first async operation will perform @c s.dispatch(a),
* and the second will perform @c s.dispatch(b), but the order in which those
* are performed is unspecified. That is, you cannot state whether one
* happens-before the other. Therefore none of the above conditions are met and
* no ordering guarantee is made.
*
* @note The implementation makes no guarantee that handlers posted or
* dispatched through different @c strand objects will be invoked concurrently.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Safe.
*
* @par Concepts:
* Dispatcher.
*/
class io_service::strand
{
public:
/// Constructor.
/**
* Constructs the strand.
*
* @param io_service The io_service object that the strand will use to
* dispatch handlers that are ready to be run.
*/
explicit strand(asio::io_service& io_service)
: service_(asio::use_service<
asio::detail::strand_service>(io_service))
{
service_.construct(impl_);
}
/// Destructor.
/**
* Destroys a strand.
*
* Handlers posted through the strand that have not yet been invoked will
* still be dispatched in a way that meets the guarantee of non-concurrency.
*/
~strand()
{
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use context().) Get the io_service associated with the
/// strand.
/**
* This function may be used to obtain the io_service object that the strand
* uses to dispatch handlers for asynchronous operations.
*
* @return A reference to the io_service object that the strand will use to
* dispatch handlers. Ownership is not transferred to the caller.
*/
asio::io_service& get_io_service()
{
return service_.get_io_service();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Obtain the underlying execution context.
asio::io_service& context() ASIO_NOEXCEPT
{
return service_.get_io_service();
}
/// Inform the strand that it has some outstanding work to do.
/**
* The strand delegates this call to its underlying io_service.
*/
void on_work_started() ASIO_NOEXCEPT
{
context().get_executor().on_work_started();
}
/// Inform the strand that some work is no longer outstanding.
/**
* The strand delegates this call to its underlying io_service.
*/
void on_work_finished() ASIO_NOEXCEPT
{
context().get_executor().on_work_finished();
}
/// Request the strand to invoke the given function object.
/**
* This function is used to ask the strand to execute the given function
* object on its underlying io_service. The function object will be executed
* inside this function if the strand is not otherwise busy and if the
* underlying io_service's executor's @c dispatch() function is also able to
* execute the function before returning.
*
* @param f The function object to be called. The executor will make
* a copy of the handler object as required. The function signature of the
* function object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
service_.dispatch(impl_, tmp);
(void)a;
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use asio::dispatch().) Request the strand to invoke
/// the given handler.
/**
* This function is used to ask the strand to execute the given handler.
*
* The strand object guarantees that handlers posted or dispatched through
* the strand will not be executed concurrently. The handler may be executed
* inside this function if the guarantee can be met. If this function is
* called from within a handler that was posted or dispatched through the same
* strand, then the new handler will be executed immediately.
*
* The strand's guarantee is in addition to the guarantee provided by the
* underlying io_service. The io_service guarantees that the handler will only
* be called in a thread in which the io_service's run member function is
* currently being invoked.
*
* @param handler The handler to be called. The strand will make a copy of the
* handler object as required. The function signature of the handler must be:
* @code void handler(); @endcode
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
dispatch(ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
async_completion<CompletionHandler, void ()> init(handler);
service_.dispatch(impl_, init.handler);
return init.result.get();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Request the strand to invoke the given function object.
/**
* This function is used to ask the executor to execute the given function
* object. The function object will never be executed inside this function.
* Instead, it will be scheduled to run by the underlying io_service.
*
* @param f The function object to be called. The executor will make
* a copy of the handler object as required. The function signature of the
* function object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void post(ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
service_.post(impl_, tmp);
(void)a;
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use asio::post().) Request the strand to invoke the
/// given handler and return immediately.
/**
* This function is used to ask the strand to execute the given handler, but
* without allowing the strand to call the handler from inside this function.
*
* The strand object guarantees that handlers posted or dispatched through
* the strand will not be executed concurrently. The strand's guarantee is in
* addition to the guarantee provided by the underlying io_service. The
* io_service guarantees that the handler will only be called in a thread in
* which the io_service's run member function is currently being invoked.
*
* @param handler The handler to be called. The strand will make a copy of the
* handler object as required. The function signature of the handler must be:
* @code void handler(); @endcode
*/
template <typename CompletionHandler>
ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
post(ASIO_MOVE_ARG(CompletionHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a CompletionHandler.
ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
async_completion<CompletionHandler, void ()> init(handler);
service_.post(impl_, init.handler);
return init.result.get();
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Request the strand to invoke the given function object.
/**
* This function is used to ask the executor to execute the given function
* object. The function object will never be executed inside this function.
* Instead, it will be scheduled to run by the underlying io_service.
*
* @param f The function object to be called. The executor will make
* a copy of the handler object as required. The function signature of the
* function object must be: @code void function(); @endcode
*
* @param a An allocator that may be used by the executor to allocate the
* internal storage needed for function invocation.
*/
template <typename Function, typename Allocator>
void defer(ASIO_MOVE_ARG(Function) f, const Allocator& a)
{
typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
service_.post(impl_, tmp);
(void)a;
}
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use asio::bind_executor().) Create a new handler that
/// automatically dispatches the wrapped handler on the strand.
/**
* This function is used to create a new handler function object that, when
* invoked, will automatically pass the wrapped handler to the strand's
* dispatch function.
*
* @param handler The handler to be wrapped. The strand will make a copy of
* the handler object as required. The function signature of the handler must
* be: @code void handler(A1 a1, ... An an); @endcode
*
* @return A function object that, when invoked, passes the wrapped handler to
* the strand's dispatch function. Given a function object with the signature:
* @code R f(A1 a1, ... An an); @endcode
* If this function object is passed to the wrap function like so:
* @code strand.wrap(f); @endcode
* then the return value is a function object with the signature
* @code void g(A1 a1, ... An an); @endcode
* that, when invoked, executes code equivalent to:
* @code strand.dispatch(boost::bind(f, a1, ... an)); @endcode
*/
template <typename Handler>
#if defined(GENERATING_DOCUMENTATION)
unspecified
#else
detail::wrapped_handler<strand, Handler, detail::is_continuation_if_running>
#endif
wrap(Handler handler)
{
return detail::wrapped_handler<io_service::strand, Handler,
detail::is_continuation_if_running>(*this, handler);
}
#endif // !defined(ASIO_NO_DEPRECATED)
/// Determine whether the strand is running in the current thread.
/**
* @return @c true if the current thread is executing a handler that was
* submitted to the strand using post(), dispatch() or wrap(). Otherwise
* returns @c false.
*/
bool running_in_this_thread() const ASIO_NOEXCEPT
{
return service_.running_in_this_thread(impl_);
}
/// Compare two strands for equality.
/**
* Two strands are equal if they refer to the same ordered, non-concurrent
* state.
*/
friend bool operator==(const strand& a, const strand& b) ASIO_NOEXCEPT
{
return a.impl_ == b.impl_;
}
/// Compare two strands for inequality.
/**
* Two strands are equal if they refer to the same ordered, non-concurrent
* state.
*/
friend bool operator!=(const strand& a, const strand& b) ASIO_NOEXCEPT
{
return a.impl_ != b.impl_;
}
private:
asio::detail::strand_service& service_;
asio::detail::strand_service::implementation_type impl_;
};
#if !defined(GENERATING_DOCUMENTATION)
template <>
struct is_executor<io_service::strand> : true_type {};
#endif // !defined(GENERATING_DOCUMENTATION)
} // namespace asio
#include "asio/detail/pop_options.hpp"
#include "asio/io_context_strand.hpp"
#endif // ASIO_IO_SERVICE_STRAND_HPP

View File

@ -69,11 +69,11 @@ public:
/**
* This constructor creates a basic_resolver.
*
* @param io_service The io_service object that the resolver will use to
* @param io_context The io_context object that the resolver will use to
* dispatch handlers for any asynchronous operations performed on the timer.
*/
explicit basic_resolver(asio::io_service& io_service)
: basic_io_object<ResolverService>(io_service)
explicit basic_resolver(asio::io_context& io_context)
: basic_io_object<ResolverService>(io_context)
{
}
@ -501,7 +501,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* A successful resolve operation is guaranteed to pass a non-empty range to
* the handler.
@ -548,7 +548,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* A successful resolve operation is guaranteed to pass a non-empty range to
* the handler.
@ -604,7 +604,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* A successful resolve operation is guaranteed to pass a non-empty range to
* the handler.
@ -666,7 +666,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* A successful resolve operation is guaranteed to pass a non-empty range to
* the handler.
@ -725,7 +725,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* A successful resolve operation is guaranteed to pass a non-empty range to
* the handler.
@ -820,7 +820,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* A successful resolve operation is guaranteed to pass a non-empty range to
* the handler.

View File

@ -32,7 +32,7 @@ namespace multicast {
* @par Examples
* Setting the option to join a multicast group:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::address multicast_address =
* asio::ip::address::from_string("225.0.0.1");
@ -60,7 +60,7 @@ typedef asio::ip::detail::socket_option::multicast_request<
* @par Examples
* Setting the option to leave a multicast group:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::address multicast_address =
* asio::ip::address::from_string("225.0.0.1");
@ -88,7 +88,7 @@ typedef asio::ip::detail::socket_option::multicast_request<
* @par Examples
* Setting the option:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::address_v4 local_interface =
* asio::ip::address_v4::from_string("1.2.3.4");
@ -116,7 +116,7 @@ typedef asio::ip::detail::socket_option::network_interface<
* @par Examples
* Setting the option:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::hops option(4);
* socket.set_option(option);
@ -125,7 +125,7 @@ typedef asio::ip::detail::socket_option::network_interface<
* @par
* Getting the current option value:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::hops option;
* socket.get_option(option);
@ -153,7 +153,7 @@ typedef asio::ip::detail::socket_option::multicast_hops<
* @par Examples
* Setting the option:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::enable_loopback option(true);
* socket.set_option(option);
@ -162,7 +162,7 @@ typedef asio::ip::detail::socket_option::multicast_hops<
* @par
* Getting the current option value:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::multicast::enable_loopback option;
* socket.get_option(option);

View File

@ -18,7 +18,7 @@
#include "asio/detail/config.hpp"
#include "asio/async_result.hpp"
#include "asio/error_code.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/ip/basic_resolver_iterator.hpp"
#include "asio/ip/basic_resolver_query.hpp"
#include "asio/ip/basic_resolver_results.hpp"
@ -38,7 +38,7 @@ namespace ip {
template <typename InternetProtocol>
class resolver_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<
resolver_service<InternetProtocol> >
@ -47,7 +47,7 @@ class resolver_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
/// The protocol type.
@ -83,11 +83,11 @@ public:
typedef typename service_impl_type::implementation_type implementation_type;
#endif
/// Construct a new resolver service for the specified io_service.
explicit resolver_service(asio::io_service& io_service)
/// Construct a new resolver service for the specified io_context.
explicit resolver_service(asio::io_context& io_context)
: asio::detail::service_base<
resolver_service<InternetProtocol> >(io_service),
service_impl_(io_service)
resolver_service<InternetProtocol> >(io_context),
service_impl_(io_context)
{
}
@ -161,7 +161,7 @@ private:
}
// Perform any fork-related housekeeping.
void fork_service(asio::io_service::fork_event event)
void fork_service(asio::io_context::fork_event event)
{
service_impl_.fork_service(event);
}

View File

@ -99,7 +99,7 @@ public:
* @par Examples
* Setting the option:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::no_delay option(true);
* socket.set_option(option);
@ -108,7 +108,7 @@ public:
* @par
* Getting the current option value:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::tcp::no_delay option;
* socket.get_option(option);

View File

@ -32,7 +32,7 @@ namespace unicast {
* @par Examples
* Setting the option:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::unicast::hops option(4);
* socket.set_option(option);
@ -41,7 +41,7 @@ namespace unicast {
* @par
* Getting the current option value:
* @code
* asio::ip::udp::socket socket(io_service);
* asio::ip::udp::socket socket(io_context);
* ...
* asio::ip::unicast::hops option;
* socket.get_option(option);

View File

@ -31,7 +31,7 @@ namespace ip {
* @par Examples
* Setting the option:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::v6_only option(true);
* socket.set_option(option);
@ -40,7 +40,7 @@ namespace ip {
* @par
* Getting the current option value:
* @code
* asio::ip::tcp::socket socket(io_service);
* asio::ip::tcp::socket socket(io_context);
* ...
* asio::ip::v6_only option;
* socket.get_option(option);

View File

@ -55,12 +55,12 @@ public:
/**
* This constructor creates a descriptor without opening it.
*
* @param io_service The io_service object that the descriptor will use to
* @param io_context The io_context object that the descriptor will use to
* dispatch handlers for any asynchronous operations performed on the
* descriptor.
*/
explicit basic_descriptor(asio::io_service& io_service)
: basic_io_object<DescriptorService>(io_service)
explicit basic_descriptor(asio::io_context& io_context)
: basic_io_object<DescriptorService>(io_context)
{
}
@ -69,7 +69,7 @@ public:
* This constructor creates a descriptor object to hold an existing native
* descriptor.
*
* @param io_service The io_service object that the descriptor will use to
* @param io_context The io_context object that the descriptor will use to
* dispatch handlers for any asynchronous operations performed on the
* descriptor.
*
@ -77,9 +77,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_descriptor(asio::io_service& io_service,
basic_descriptor(asio::io_context& io_context,
const native_handle_type& native_descriptor)
: basic_io_object<DescriptorService>(io_service)
: basic_io_object<DescriptorService>(io_context)
{
asio::error_code ec;
this->get_service().assign(this->get_implementation(),
@ -96,7 +96,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_descriptor(io_service&) constructor.
* constructed using the @c basic_descriptor(io_context&) constructor.
*/
basic_descriptor(basic_descriptor&& other)
: basic_io_object<DescriptorService>(
@ -112,7 +112,7 @@ public:
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_descriptor(io_service&) constructor.
* constructed using the @c basic_descriptor(io_context&) constructor.
*/
basic_descriptor& operator=(basic_descriptor&& other)
{
@ -286,7 +286,7 @@ public:
* @par Example
* Getting the number of bytes ready to read:
* @code
* asio::posix::stream_descriptor descriptor(io_service);
* asio::posix::stream_descriptor descriptor(io_context);
* ...
* asio::posix::stream_descriptor::bytes_readable command;
* descriptor.io_control(command);
@ -316,7 +316,7 @@ public:
* @par Example
* Getting the number of bytes ready to read:
* @code
* asio::posix::stream_descriptor descriptor(io_service);
* asio::posix::stream_descriptor descriptor(io_context);
* ...
* asio::posix::stream_descriptor::bytes_readable command;
* asio::error_code ec;
@ -468,7 +468,7 @@ public:
* @par Example
* Waiting for a descriptor to become readable.
* @code
* asio::posix::stream_descriptor descriptor(io_service);
* asio::posix::stream_descriptor descriptor(io_context);
* ...
* descriptor.wait(asio::posix::stream_descriptor::wait_read);
* @endcode
@ -493,7 +493,7 @@ public:
* @par Example
* Waiting for a descriptor to become readable.
* @code
* asio::posix::stream_descriptor descriptor(io_service);
* asio::posix::stream_descriptor descriptor(io_context);
* ...
* asio::error_code ec;
* descriptor.wait(asio::posix::stream_descriptor::wait_read, ec);
@ -521,7 +521,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* @code
@ -535,7 +535,7 @@ public:
*
* ...
*
* asio::posix::stream_descriptor descriptor(io_service);
* asio::posix::stream_descriptor descriptor(io_context);
* ...
* descriptor.async_wait(
* asio::posix::stream_descriptor::wait_read,

View File

@ -59,12 +59,12 @@ public:
* descriptor needs to be opened and then connected or accepted before data
* can be sent or received on it.
*
* @param io_service The io_service object that the stream descriptor will
* @param io_context The io_context object that the stream descriptor will
* use to dispatch handlers for any asynchronous operations performed on the
* descriptor.
*/
explicit basic_stream_descriptor(asio::io_service& io_service)
: basic_descriptor<StreamDescriptorService>(io_service)
explicit basic_stream_descriptor(asio::io_context& io_context)
: basic_descriptor<StreamDescriptorService>(io_context)
{
}
@ -73,7 +73,7 @@ public:
* This constructor creates a stream descriptor object to hold an existing
* native descriptor.
*
* @param io_service The io_service object that the stream descriptor will
* @param io_context The io_context object that the stream descriptor will
* use to dispatch handlers for any asynchronous operations performed on the
* descriptor.
*
@ -81,9 +81,9 @@ public:
*
* @throws asio::system_error Thrown on failure.
*/
basic_stream_descriptor(asio::io_service& io_service,
basic_stream_descriptor(asio::io_context& io_context,
const native_handle_type& native_descriptor)
: basic_descriptor<StreamDescriptorService>(io_service, native_descriptor)
: basic_descriptor<StreamDescriptorService>(io_context, native_descriptor)
{
}
@ -96,7 +96,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_descriptor(io_service&) constructor.
* constructed using the @c basic_stream_descriptor(io_context&) constructor.
*/
basic_stream_descriptor(basic_stream_descriptor&& other)
: basic_descriptor<StreamDescriptorService>(
@ -113,7 +113,7 @@ public:
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_descriptor(io_service&) constructor.
* constructed using the @c basic_stream_descriptor(io_context&) constructor.
*/
basic_stream_descriptor& operator=(basic_stream_descriptor&& other)
{
@ -204,7 +204,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The write operation may not transmit all of the data to the peer.
* Consider using the @ref async_write function if you need to ensure that all
@ -316,7 +316,7 @@ public:
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation
* of the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note The read operation may not read all of the requested number of bytes.
* Consider using the @ref async_read function if you need to ensure that the

View File

@ -57,7 +57,7 @@ public:
*
* @par Example
* @code
* asio::posix::stream_descriptor descriptor(io_service);
* asio::posix::stream_descriptor descriptor(io_context);
* ...
* asio::descriptor_base::bytes_readable command(true);
* descriptor.io_control(command);

View File

@ -23,7 +23,7 @@
#include <cstddef>
#include "asio/async_result.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/reactive_descriptor_service.hpp"
#include "asio/detail/push_options.hpp"
@ -34,7 +34,7 @@ namespace posix {
/// Default service implementation for a stream descriptor.
class stream_descriptor_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<stream_descriptor_service>
#endif
@ -42,7 +42,7 @@ class stream_descriptor_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
private:
@ -64,10 +64,10 @@ public:
typedef service_impl_type::native_handle_type native_handle_type;
#endif
/// Construct a new stream descriptor service for the specified io_service.
explicit stream_descriptor_service(asio::io_service& io_service)
: asio::detail::service_base<stream_descriptor_service>(io_service),
service_impl_(io_service)
/// Construct a new stream descriptor service for the specified io_context.
explicit stream_descriptor_service(asio::io_context& io_context)
: asio::detail::service_base<stream_descriptor_service>(io_context),
service_impl_(io_context)
{
}

View File

@ -20,7 +20,7 @@
#include "asio/async_result.hpp"
#include "asio/detail/type_traits.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#if defined(ASIO_WINDOWS_RUNTIME)
# include "asio/detail/null_socket_service.hpp"
@ -38,7 +38,7 @@ namespace asio {
template <typename Protocol>
class raw_socket_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<raw_socket_service<Protocol> >
#endif
@ -46,7 +46,7 @@ class raw_socket_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
/// The protocol type.
@ -80,11 +80,11 @@ public:
typedef typename service_impl_type::native_handle_type native_handle_type;
#endif
/// Construct a new raw socket service for the specified io_service.
explicit raw_socket_service(asio::io_service& io_service)
/// Construct a new raw socket service for the specified io_context.
explicit raw_socket_service(asio::io_context& io_context)
: asio::detail::service_base<
raw_socket_service<Protocol> >(io_service),
service_impl_(io_service)
raw_socket_service<Protocol> >(io_context),
service_impl_(io_context)
{
}

View File

@ -575,7 +575,7 @@ std::size_t read(SyncReadStream& s, basic_streambuf<Allocator>& b,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
@ -653,7 +653,7 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
@ -718,7 +718,7 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note This overload is equivalent to calling:
* @code asio::async_read(
@ -793,7 +793,7 @@ async_read(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename AsyncReadStream, typename DynamicBufferSequence,
typename CompletionCondition, typename ReadHandler>
@ -849,7 +849,7 @@ async_read(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note This overload is equivalent to calling:
* @code asio::async_read(
@ -917,7 +917,7 @@ async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename AsyncReadStream, typename Allocator,
typename CompletionCondition, typename ReadHandler>

View File

@ -436,7 +436,7 @@ std::size_t read_at(SyncRandomAccessReadDevice& d,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
@ -514,7 +514,7 @@ async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @par Example
* To read into a single data buffer use the @ref buffer function as follows:
@ -574,7 +574,7 @@ async_read_at(AsyncRandomAccessReadDevice& d,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note This overload is equivalent to calling:
* @code asio::async_read_at(
@ -640,7 +640,7 @@ async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*/
template <typename AsyncRandomAccessReadDevice, typename Allocator,
typename CompletionCondition, typename ReadHandler>

View File

@ -1034,7 +1034,7 @@ std::size_t read_until(SyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond the delimiter. An application
@ -1124,7 +1124,7 @@ async_read_until(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond the delimiter. An application
@ -1220,7 +1220,7 @@ async_read_until(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond that which matched the regular
@ -1329,7 +1329,7 @@ async_read_until(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond that which matched the function
@ -1451,7 +1451,7 @@ async_read_until(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the streambuf may
* contain additional data beyond the delimiter. An application will typically
@ -1536,7 +1536,7 @@ async_read_until(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the streambuf may
* contain additional data beyond the delimiter. An application will typically
@ -1627,7 +1627,7 @@ async_read_until(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the streambuf may
* contain additional data beyond that which matched the regular expression. An
@ -1729,7 +1729,7 @@ async_read_until(AsyncReadStream& s,
* Regardless of whether the asynchronous operation completes immediately or
* not, the handler will not be invoked from within this function. Invocation of
* the handler will be performed in a manner equivalent to using
* asio::io_service::post().
* asio::io_context::post().
*
* @note After a successful async_read_until operation, the streambuf may
* contain additional data beyond that which matched the function object. An

View File

@ -20,7 +20,7 @@
#include "asio/async_result.hpp"
#include "asio/detail/type_traits.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#if defined(ASIO_WINDOWS_RUNTIME)
# include "asio/detail/null_socket_service.hpp"
@ -38,7 +38,7 @@ namespace asio {
template <typename Protocol>
class seq_packet_socket_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<
seq_packet_socket_service<Protocol> >
@ -47,7 +47,7 @@ class seq_packet_socket_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
/// The protocol type.
@ -82,11 +82,11 @@ public:
#endif
/// Construct a new sequenced packet socket service for the specified
/// io_service.
explicit seq_packet_socket_service(asio::io_service& io_service)
/// io_context.
explicit seq_packet_socket_service(asio::io_context& io_context)
: asio::detail::service_base<
seq_packet_socket_service<Protocol> >(io_service),
service_impl_(io_service)
seq_packet_socket_service<Protocol> >(io_context),
service_impl_(io_context)
{
}

View File

@ -26,7 +26,7 @@
#include "asio/detail/reactive_serial_port_service.hpp"
#include "asio/detail/win_iocp_serial_port_service.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/serial_port_base.hpp"
#include "asio/detail/push_options.hpp"
@ -36,7 +36,7 @@ namespace asio {
/// Default service implementation for a serial port.
class serial_port_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<serial_port_service>
#endif
@ -44,7 +44,7 @@ class serial_port_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
private:
@ -70,10 +70,10 @@ public:
typedef service_impl_type::native_handle_type native_handle_type;
#endif
/// Construct a new serial port service for the specified io_service.
explicit serial_port_service(asio::io_service& io_service)
: asio::detail::service_base<serial_port_service>(io_service),
service_impl_(io_service)
/// Construct a new serial port service for the specified io_context.
explicit serial_port_service(asio::io_context& io_context)
: asio::detail::service_base<serial_port_service>(io_context),
service_impl_(io_context)
{
}

View File

@ -19,7 +19,7 @@
#include "asio/async_result.hpp"
#include "asio/detail/signal_set_service.hpp"
#include "asio/error.hpp"
#include "asio/io_service.hpp"
#include "asio/io_context.hpp"
#include "asio/detail/push_options.hpp"
@ -28,7 +28,7 @@ namespace asio {
/// Default service implementation for a signal set.
class signal_set_service
#if defined(GENERATING_DOCUMENTATION)
: public asio::io_service::service
: public asio::io_context::service
#else
: public asio::detail::service_base<signal_set_service>
#endif
@ -36,7 +36,7 @@ class signal_set_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
static asio::io_service::id id;
static asio::io_context::id id;
#endif
public:
@ -47,10 +47,10 @@ public:
typedef detail::signal_set_service::implementation_type implementation_type;
#endif
/// Construct a new signal set service for the specified io_service.
explicit signal_set_service(asio::io_service& io_service)
: asio::detail::service_base<signal_set_service>(io_service),
service_impl_(io_service)
/// Construct a new signal set service for the specified io_context.
explicit signal_set_service(asio::io_context& io_context)
: asio::detail::service_base<signal_set_service>(io_context),
service_impl_(io_context)
{
}
@ -117,7 +117,7 @@ private:
}
// Perform any fork-related housekeeping.
void fork_service(asio::io_service::fork_event event)
void fork_service(asio::io_context::fork_event event)
{
service_impl_.fork_service(event);
}

Some files were not shown because too many files have changed in this diff Show More