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 a snapshot of the master branch, built from commit eef40d496b.
PrevUpHomeNext
connection_pool::async_run

Runs the pool task in charge of managing connections.

Synopsis
template<
    class CompletionToken = with_diagnostics_t<asio::deferred_t>>
auto
async_run(
    CompletionToken&& token = {});
Description

This function creates and connects new connections, and resets and pings already created ones. You need to call this function for async_get_connection to succeed.

The async operation will run indefinitely, until the pool is cancelled (by calling cancel or using per-operation cancellation on the async_run operation). The operation completes once all internal connection operations (including connects, pings and resets) complete.

It is safe to call this function after calling cancel.

Preconditions

This function can be called at most once for a single pool. Formally, async_run hasn't been called before on *this or any object used to move-construct or move-assign *this.

Additionally, this->valid() == true.

Object lifetimes

While the operation is outstanding, the pool's internal data will be kept alive. It is safe to destroy *this while the operation is outstanding.

Handler signature

The handler signature for this operation is void(boost::mysql::error_code)

Executor

The final handler is executed using token's associated executor, or this->get_executor() if the token doesn't have an associated executor. The final handler is called as if it was submitted using asio::post, and is never be called inline from within this function.

If the pool was constructed with thread-safety enabled, intermediate completion handlers are executed using an internal strand that wraps this->get_executor(). Otherwise, intermediate handlers are executed using this->get_executor(). In any case, the token's associated executor is only used for the final handler.

Per-operation cancellation

This operation supports per-operation cancellation. Cancelling async_run is equivalent to calling connection_pool::cancel. The following asio::cancellation_type_t values are supported:

Note that asio::cancellation_type_t::total is not supported because invoking async_run always has observable side effects.

Errors

This function always complete successfully. The handler signature ensures maximum compatibility with Boost.Asio infrastructure.

Thread-safety

Reads the internal state handle. Mutates the pool state. If the pool was built with thread-safety enabled, it can be called concurrently with other functions that don't modify the state handle.


PrevUpHomeNext