#include <io_service.hpp>
Inherits asio::detail::noncopyable.
Public Member Functions | |
| io_service () | |
| Constructor. | |
| io_service (std::size_t concurrency_hint) | |
| Constructor. | |
| ~io_service () | |
| Destructor. | |
| std::size_t | run () |
| Run the io_service's event processing loop. | |
| std::size_t | run (asio::error_code &ec) |
| Run the io_service's event processing loop. | |
| std::size_t | run_one () |
| Run the io_service's event processing loop to execute at most one handler. | |
| std::size_t | run_one (asio::error_code &ec) |
| Run the io_service's event processing loop to execute at most one handler. | |
| std::size_t | poll () |
| Run the io_service's event processing loop to execute ready handlers. | |
| std::size_t | poll (asio::error_code &ec) |
| Run the io_service's event processing loop to execute ready handlers. | |
| std::size_t | poll_one () |
| Run the io_service's event processing loop to execute one ready handler. | |
| std::size_t | poll_one (asio::error_code &ec) |
| Run the io_service's event processing loop to execute one ready handler. | |
| void | stop () |
| Stop the io_service's event processing loop. | |
| void | reset () |
| Reset the io_service in preparation for a subsequent run() invocation. | |
| template<typename CompletionHandler> | |
| void | dispatch (CompletionHandler handler) |
| Request the io_service to invoke the given handler. | |
| template<typename CompletionHandler> | |
| void | post (CompletionHandler handler) |
| Request the io_service to invoke the given handler and return immediately. | |
| template<typename Handler> | |
| detail::wrapped_handler < io_service, Handler > | wrap (Handler handler) |
Private Types | |
| typedef detail::task_io_service < detail::select_reactor < false > > | impl_type |
Private Attributes | |
| asio::detail::service_registry * | service_registry_ |
| impl_type & | impl_ |
Friends | |
| class | work |
| template<typename Service> | |
| Service & | use_service (io_service &ios) |
| Obtain the service object corresponding to the given type. | |
| template<typename Service> | |
| void | add_service (io_service &ios, Service *svc) |
| Add a service object to the io_service. | |
| template<typename Service> | |
| bool | has_service (io_service &ios) |
| Determine if an io_service contains a specified service type. | |
Classes | |
| class | id |
| Class used to uniquely identify a service. More... | |
| class | service |
| Base class for all io_service services. More... | |
| class | strand |
| Provides serialised handler execution. More... | |
| class | work |
| Class to inform the io_service when it has work to do. More... | |
The io_service class provides the core I/O functionality for users of the asynchronous I/O objects, including:
The io_service class also includes facilities intended for developers of custom asynchronous services.
Definition at line 65 of file io_service.hpp.
typedef detail::task_io_service<detail::select_reactor<false> > asio::io_service::impl_type [private] |
Definition at line 77 of file io_service.hpp.
| asio::io_service::io_service | ( | ) | [inline] |
Constructor.
Definition at line 34 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::init().
Referenced by asio::add_service().
| asio::io_service::io_service | ( | std::size_t | concurrency_hint | ) | [inline, explicit] |
Constructor.
Construct with a hint about the required level of concurrency.
| concurrency_hint | A suggestion to the implementation on how many threads it should allow to run simultaneously. |
Definition at line 41 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::init().
| asio::io_service::~io_service | ( | ) | [inline] |
| std::size_t asio::io_service::run | ( | ) | [inline] |
Run the io_service'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.
The run() function may be safely called again once it has completed only after a call to reset().
| asio::system_error | Thrown on failure. |
Definition at line 53 of file io_service.ipp.
References impl_, asio::detail::task_io_service< Task >::run(), simple_client::s, and asio::detail::throw_error().
Referenced by libtorrent::aux::session_impl::operator()().
| std::size_t asio::io_service::run | ( | asio::error_code & | ec | ) | [inline] |
Run the io_service'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.
The run() function may be safely called again once it has completed only after a call to reset().
| ec | Set to indicate what error occurred, if any. |
Definition at line 61 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::run().
| std::size_t asio::io_service::run_one | ( | ) | [inline] |
Run the io_service'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.
| asio::system_error | Thrown on failure. |
Definition at line 66 of file io_service.ipp.
References impl_, asio::detail::task_io_service< Task >::run_one(), simple_client::s, and asio::detail::throw_error().
| std::size_t asio::io_service::run_one | ( | asio::error_code & | ec | ) | [inline] |
Run the io_service'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.
| ec | Set to indicate what error occurred, if any. |
Definition at line 74 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::run_one().
| std::size_t asio::io_service::poll | ( | ) | [inline] |
Run the io_service'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.
| asio::system_error | Thrown on failure. |
Definition at line 79 of file io_service.ipp.
References impl_, asio::detail::task_io_service< Task >::poll(), simple_client::s, and asio::detail::throw_error().
| std::size_t asio::io_service::poll | ( | asio::error_code & | ec | ) | [inline] |
Run the io_service'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.
| ec | Set to indicate what error occurred, if any. |
Definition at line 87 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::poll().
| std::size_t asio::io_service::poll_one | ( | ) | [inline] |
Run the io_service'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.
| asio::system_error | Thrown on failure. |
Definition at line 92 of file io_service.ipp.
References impl_, asio::detail::task_io_service< Task >::poll_one(), simple_client::s, and asio::detail::throw_error().
| std::size_t asio::io_service::poll_one | ( | asio::error_code & | ec | ) | [inline] |
Run the io_service'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.
| ec | Set to indicate what error occurred, if any. |
Definition at line 100 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::poll_one().
| void asio::io_service::stop | ( | ) | [inline] |
Stop the io_service'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 reset() is called.
Definition at line 105 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::stop().
Referenced by libtorrent::aux::session_impl::abort(), libtorrent::aux::session_impl::operator()(), libtorrent::aux::session_impl::second_tick(), and libtorrent::aux::session_impl::~session_impl().
| void asio::io_service::reset | ( | ) | [inline] |
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. This function allows the io_service to reset any internal state, such as a "stopped" flag.
This function must not be called while there are any unfinished calls to the run(), run_one(), poll() or poll_one() functions.
Definition at line 110 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::reset().
Referenced by libtorrent::aux::session_impl::operator()().
| void asio::io_service::dispatch | ( | Handler | handler | ) | [inline] |
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.
| 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: void handler();
|
Definition at line 116 of file io_service.ipp.
References asio::detail::task_io_service< Task >::dispatch(), and impl_.
Referenced by asio::detail::strand_service::dispatch(), asio::buffered_write_stream< Stream >::write_some_handler< ConstBufferSequence, WriteHandler >::operator()(), asio::buffered_write_stream< Stream >::flush_handler< WriteHandler >::operator()(), asio::buffered_read_stream< Stream >::read_some_handler< MutableBufferSequence, ReadHandler >::operator()(), and asio::buffered_read_stream< Stream >::fill_handler< ReadHandler >::operator()().
| void asio::io_service::post | ( | Handler | handler | ) | [inline] |
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.
| 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: void handler();
|
Definition at line 122 of file io_service.ipp.
References impl_, and asio::detail::task_io_service< Task >::post().
Referenced by asio::detail::reactive_socket_service< Protocol, Reactor >::async_accept(), asio::detail::reactive_socket_service< Protocol, Reactor >::async_connect(), asio::basic_socket< Protocol, StreamSocketService >::async_connect(), asio::ssl::detail::openssl_stream_service::async_handshake(), asio::ssl::detail::openssl_stream_service::async_read_some(), asio::buffered_read_stream< asio::buffered_write_stream & >::async_read_some(), asio::detail::reactive_socket_service< Protocol, Reactor >::async_receive(), asio::detail::reactive_socket_service< Protocol, Reactor >::async_receive_from(), asio::detail::reactive_socket_service< Protocol, Reactor >::async_send(), asio::detail::reactive_socket_service< Protocol, Reactor >::async_send_to(), asio::ssl::detail::openssl_stream_service::async_shutdown(), asio::ssl::detail::openssl_stream_service::async_write_some(), asio::buffered_write_stream< Stream >::async_write_some(), libtorrent::peer_connection::disconnect(), asio::detail::reactive_socket_service< Protocol, Reactor >::connect_handler< Handler >::operator()(), asio::detail::reactive_socket_service< Protocol, Reactor >::accept_handler< Socket, Handler >::operator()(), asio::detail::reactive_socket_service< Protocol, Reactor >::receive_from_handler< MutableBufferSequence, Handler >::operator()(), asio::detail::reactive_socket_service< Protocol, Reactor >::receive_handler< MutableBufferSequence, Handler >::operator()(), asio::detail::reactive_socket_service< Protocol, Reactor >::send_to_handler< ConstBufferSequence, Handler >::operator()(), asio::detail::reactive_socket_service< Protocol, Reactor >::send_handler< ConstBufferSequence, Handler >::operator()(), asio::detail::deadline_timer_service< Time_Traits, Timer_Scheduler >::wait_handler< Handler >::operator()(), asio::detail::strand_service::post(), and asio::detail::strand_service::post_next_waiter_on_exit::~post_next_waiter_on_exit().
| detail::wrapped_handler< io_service, Handler > asio::io_service::wrap | ( | Handler | handler | ) | [inline] |
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's dispatch function.
| 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: void handler(A1 a1, ... An an);
|
R f(A1 a1, ... An an);
io_service.wrap(f);
void g(A1 a1, ... An an);
io_service.dispatch(boost::bind(f, a1, ... an));
Definition at line 133 of file io_service.ipp.
friend class work [friend] |
Definition at line 81 of file io_service.hpp.
| Service& use_service | ( | io_service & | ios | ) | [friend] |
Obtain the service object corresponding to the given type.
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.
| ios | The io_service object that owns the service. |
Definition at line 177 of file io_service.ipp.
| void add_service | ( | io_service & | ios, | |
| Service * | svc | |||
| ) | [friend] |
Add a service object to the io_service.
This function is used to add a service to the io_service.
| ios | The io_service object that owns the service. | |
| svc | The service object. On success, ownership of the service object is transferred to the io_service. When the io_service object is destroyed, it will destroy the service object by performing: delete static_cast<io_service::service*>(svc) |
| asio::service_already_exists | Thrown if a service of the given type is already present in the io_service. | |
| asio::invalid_service_owner | Thrown if the service's owning io_service is not the io_service object specified by the ios parameter. |
Definition at line 187 of file io_service.ipp.
| bool has_service | ( | io_service & | ios | ) | [friend] |
Determine if an io_service contains a specified service type.
This function is used to determine whether the io_service contains a service object corresponding to the given service type.
| ios | The io_service object that owns the service. |
Definition at line 200 of file io_service.ipp.
Definition at line 344 of file io_service.hpp.
Referenced by asio::add_service(), asio::has_service(), asio::use_service(), and ~io_service().
impl_type& asio::io_service::impl_ [private] |
Definition at line 347 of file io_service.hpp.
Referenced by dispatch(), io_service(), poll(), poll_one(), post(), reset(), run(), run_one(), stop(), asio::io_service::work::work(), and asio::io_service::work::~work().
1.5.6