...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Enables or disables thread-safety.
bool thread_safe {false};
When set to true
, the resulting
connection pool are able to be shared between threads at the cost of some
performance.
Enabling thread safety for a pool creates an internal asio::strand
object wrapping the executor passed to the pool's constructor. All state-mutating
functions (including connection_pool::async_run
, connection_pool::async_get_connection
and returning
connections) will be run through the created strand.
Thread-safety doesn't extend to individual connections: pooled_connection
objects can't
be shared between threads. Thread-safety does not protect objects that
don't belong to the pool. For instance, asio::cancel_after
creates a timer that must be protected with a strand. Refer to this
page for more info.