asio C++ library

PrevUpHomeNext
io_service::run (2 of 2 overloads)

Run the io_service object's event processing loop.

std::size_t run(
    asio::error_code & ec);

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 true). Subsequent calls to run(), run_one(), poll() or poll_one() will return immediately unless there is a prior call to reset().

Parameters

ec

Set to indicate what error occurred, if any.

Return Value

The number of handlers that were executed.

Remarks

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.


PrevUpHomeNext