...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Runs the pool task in charge of managing connections.
template<
class CompletionToken = with_diagnostics_t
<asio::deferred_t>>
auto
async_run(
CompletionToken&& token = {});
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
.
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
.
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.
The handler signature for this operation is void(boost::mysql::error_code)
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.
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:
asio::cancellation_type_t::terminal
asio::cancellation_type_t::partial
Note that asio::cancellation_type_t::total
is not supported because invoking
async_run
always has observable
side effects.
This function always complete successfully. The handler signature ensures maximum compatibility with Boost.Asio infrastructure.
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.