Boost C++ Libraries 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.
io_context::run_one (1 of 2 overloads)

Run the io_context object's event processing loop to execute at most one handler.

count_type run_one();

The run_one() function blocks until one handler has been dispatched, or until the io_context has been stopped.

Return Value

The number of handlers that were executed. A zero return value 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().


Calling the run_one() 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.