| Home | Libraries | People | FAQ | More

##### connection_pool::async_run

Runs the pool task in charge of managing connections.

###### Synopsis

    template<
        class CompletionToken>
    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 being destroyed or calling `cancel`). 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)`

###### Errors

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

###### Executor

This function will run entirely in the pool's executor (as given by `this->get_executor()`). No internal data will be accessed or modified as part of the initiating function. This simplifies thread-safety.

###### Thead-safety

When the pool is constructed with adequate executor configuration, this function is safe to be called concurrently with `async_get_connection`, `cancel`, `~pooled_connection` and `pooled_connection::return_without_reset`.