Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
io_context::run (1 of 2 overloads)

Run the io_context object's event processing loop.

count_type run();

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

Return Value

The number of handlers that were executed.

Remarks

Calling the run() function from a thread that is currently calling one of run(), run_one(), run_for(), run_until(), poll() or poll_one() on the same io_context object may introduce the potential for deadlock. It is the caller's reponsibility to avoid this.

The poll() function may also be used to dispatch ready handlers, but without blocking.


PrevUpHomeNext