Lines Matching refs:io_service
2 // io_service.hpp
32 class io_service;
33 template <typename Service> Service& use_service(io_service& ios);
34 template <typename Service> void add_service(io_service& ios, Service* svc);
35 template <typename Service> bool has_service(io_service& ios);
44 * The io_service class provides the core I/O functionality for users of the
52 * The io_service class also includes facilities intended for developers of
60 * notify_fork() function should not be called while any io_service function,
61 * or any function on an I/O object that is associated with the io_service, is
69 * Synchronous operations on I/O objects implicitly run the io_service object
70 * for an individual operation. The io_service functions run(), run_one(),
71 * poll() or poll_one() must be called for the io_service to perform
76 * io_service.
88 * call to reset(). This allows the thread to rejoin the io_service object's
94 * asio::io_service io_service;
100 * io_service.run();
110 * @par Stopping the io_service from running out of work
112 * Some applications may need to prevent an io_service object's run() call from
113 * returning when there is no more work to do. For example, the io_service may
116 * creating an object of type asio::io_service::work:
118 * @code asio::io_service io_service;
119 * asio::io_service::work work(io_service);
122 * To effect a shutdown, the application will then need to call the io_service
123 * object's stop() member function. This will cause the io_service run() call
130 * @code asio::io_service io_service;
131 * auto_ptr<asio::io_service::work> work(
132 * new asio::io_service::work(io_service));
136 * @par The io_service class and I/O services
138 * Class io_service implements an extensible, type-safe, polymorphic set of I/O
139 * services, indexed by service type. An object of class io_service must be
142 * an @c io_service& parameter.
150 * Access to the services of an io_service is via three function templates,
155 * in an io_service, an object of type @c Service is created and added to the
156 * io_service. A C++ program can check if an io_service implements a
159 * Service objects may be explicitly added to an io_service using the function
162 * not the same object as the io_service parameter, the invalid_service_owner
165 * Once a service reference is obtained from an io_service object by calling
166 * use_service(), that reference remains usable as long as the owning io_service
169 * All I/O service implementations have io_service::service as a public base
171 * then added to an io_service using the facilities described above.
173 class io_service
190 ASIO_DECL io_service();
199 ASIO_DECL explicit io_service(std::size_t concurrency_hint);
203 * On destruction, the io_service performs the following sequence of
206 * @li For each service object @c svc in the io_service set, in reverse order
211 * on the io_service, or any associated strand, are destroyed.
213 * @li For each service object @c svc in the io_service set, in reverse order
215 * <tt>delete static_cast<io_service::service*>(svc)</tt>.
228 * @li To shut down the whole program, the io_service function stop() is
229 * called to terminate any run() calls as soon as possible. The io_service
233 ASIO_DECL ~io_service();
235 /// Run the io_service object's event processing loop.
238 * more handlers to be dispatched, or until the io_service has been stopped.
241 * from which the io_service may execute handlers. All threads that are
242 * waiting in the pool are equivalent and the io_service may choose any one
245 * A normal exit from the run() function implies that the io_service object
256 * io_service object.
263 /// Run the io_service object's event processing loop.
266 * more handlers to be dispatched, or until the io_service has been stopped.
269 * from which the io_service may execute handlers. All threads that are
270 * waiting in the pool are equivalent and the io_service may choose any one
273 * A normal exit from the run() function implies that the io_service object
284 * io_service object.
291 /// Run the io_service object's event processing loop to execute at most one
295 * until the io_service has been stopped.
298 * implies that the io_service object is stopped (the stopped() function
307 /// Run the io_service object's event processing loop to execute at most one
311 * until the io_service has been stopped.
314 * implies that the io_service object is stopped (the stopped() function
323 /// Run the io_service object's event processing loop to execute ready
327 * until the io_service has been stopped or there are no more ready handlers.
335 /// Run the io_service object's event processing loop to execute ready
339 * until the io_service has been stopped or there are no more ready handlers.
347 /// Run the io_service object's event processing loop to execute one ready
359 /// Run the io_service object's event processing loop to execute one ready
371 /// Stop the io_service object's event processing loop.
373 * This function does not block, but instead simply signals the io_service to
380 /// Determine whether the io_service object has been stopped.
382 * This function is used to determine whether an io_service object has been
384 * of work. When an io_service object is stopped, calls to run(), run_one(),
388 * @return @c true if the io_service object is stopped, otherwise @c false.
392 /// Reset the io_service in preparation for a subsequent run() invocation.
396 * previous invocation of these functions returned due to the io_service
398 * io_service object's stopped() function will return @c false.
405 /// Request the io_service to invoke the given handler.
407 * This function is used to ask the io_service to execute the given handler.
409 * The io_service guarantees that the handler will only be called in a thread
414 * @param handler The handler to be called. The io_service will make
430 /// Request the io_service to invoke the given handler and return immediately.
432 * This function is used to ask the io_service to execute the given handler,
433 * but without allowing the io_service to call the handler from inside this
436 * The io_service guarantees that the handler will only be called in a thread
440 * @param handler The handler to be called. The io_service will make
457 /// on the io_service.
460 * invoked, will automatically pass the wrapped handler to the io_service
463 * @param handler The handler to be wrapped. The io_service will make a copy
468 * the io_service object's dispatch function. Given a function object with the
472 * @code io_service.wrap(f); @endcode
476 * @code io_service.dispatch(boost::bind(f, a1, ... an)); @endcode
479 detail::wrapped_handler<io_service&, Handler>
485 /// Notify the io_service that the process is about to fork.
488 /// Notify the io_service that the process has forked and is the parent.
491 /// Notify the io_service that the process has forked and is the child.
495 /// Notify the io_service of a fork-related event.
497 * This function is used to inform the io_service that the process is about
498 * to fork, or has just forked. This allows the io_service, and the services
502 * This function must not be called while any other io_service function, or
503 * any function on an I/O object associated with the io_service, is being
506 * io_service.
511 * fails the io_service object should no longer be used and should be
517 * @code my_io_service.notify_fork(asio::io_service::fork_prepare);
521 * my_io_service.notify_fork(asio::io_service::fork_child);
526 * my_io_service.notify_fork(asio::io_service::fork_parent);
529 * @note For each service object @c svc in the io_service set, performs
535 ASIO_DECL void notify_fork(asio::io_service::fork_event event);
541 * service, then the io_service will create a new instance of the service.
543 * @param ios The io_service object that owns the service.
549 friend Service& use_service(io_service& ios);
551 /// Add a service object to the io_service.
553 * This function is used to add a service to the io_service.
555 * @param ios The io_service object that owns the service.
558 * is transferred to the io_service. When the io_service object is destroyed,
560 * @code delete static_cast<io_service::service*>(svc) @endcode
563 * given type is already present in the io_service.
566 * io_service is not the io_service object specified by the ios parameter.
569 friend void add_service(io_service& ios, Service* svc);
571 /// Determine if an io_service contains a specified service type.
573 * This function is used to determine whether the io_service contains a
576 * @param ios The io_service object that owns the service.
578 * @return A boolean indicating whether the io_service contains the service.
581 friend bool has_service(io_service& ios);
595 /// Class to inform the io_service when it has work to do.
597 * The work class is used to inform the io_service when work starts and
598 * finishes. This ensures that the io_service object's run() function will not
605 class io_service::work
608 /// Constructor notifies the io_service that work is starting.
610 * The constructor is used to inform the io_service that some work has begun.
611 * This ensures that the io_service object's run() function will not exit
614 explicit work(asio::io_service& io_service);
616 /// Copy constructor notifies the io_service that work is starting.
618 * The constructor is used to inform the io_service that some work has begun.
619 * This ensures that the io_service object's run() function will not exit
624 /// Destructor notifies the io_service that the work is complete.
626 * The destructor is used to inform the io_service that some work has
627 * finished. Once the count of unfinished work reaches zero, the io_service
632 /// Get the io_service associated with the work.
633 asio::io_service& get_io_service();
639 // The io_service implementation.
644 class io_service::id
652 /// Base class for all io_service services.
653 class io_service::service
657 /// Get the io_service object that owns the service.
658 asio::io_service& get_io_service();
663 * @param owner The io_service object that owns the service.
665 ASIO_DECL service(asio::io_service& owner);
681 asio::io_service::fork_event event);
688 const asio::io_service::id* id_;
691 asio::io_service& owner_;
695 /// Exception thrown when trying to add a duplicate service to an io_service.
703 /// Exception thrown when trying to add a service object to an io_service where
717 : public asio::io_service::id
724 : public asio::io_service::service
730 service_base(asio::io_service& io_service)
731 : asio::io_service::service(io_service)
744 #include "asio/impl/io_service.hpp"
745 # include "asio/impl/io_service.ipp"