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

PrevUpHomeNext

pooled_connection

A proxy to a connection owned by a pool that returns it to the pool when destroyed.

Synopsis

Defined in header <boost/mysql/connection_pool.hpp>

class pooled_connection;
Member Functions

Name

Description

get

Retrieves the connection owned by this object.

operator->

Retrieves the connection owned by this object.

operator=

Move assignment.

pooled_connection [constructor]

Constructs an invalid pooled connection.

Move constructor.

return_without_reset

Returns the owned connection to the pool and marks it as not requiring reset.

valid

Returns whether the object owns a connection or not.

~pooled_connection [destructor]

Destructor.

Description

A pooled_connection behaves like to a std::unique_ptr: it has exclusive ownership of an any_connection created by the pool. When destroyed, it returns the connection to the pool. A pooled_connection may own nothing. We say such a connection is invalid (this->valid() == false).

This class is movable but not copyable.

Object lifetimes

While *this is alive, the connection_pool internal data will be kept alive automatically. It's safe to destroy the connection_pool object before *this.

Thread safety

This object and the any_connection object it may point to are not thread safe, even if the connection pool used to obtain them was constructed with pool_params::thread_safe set to true.

Functions that return the underlying connection to the pool cause a mutation on the pool state object. Calling such functions on objects obtained from the same pool is thread-safe only if the pool was constructed with pool_params::thread_safe set to true.

In other words, individual connections can't be shared between threads. Pools can be shared only if they're constructed with pool_params::thread_safe set to true.

Convenience header <boost/mysql.hpp>


PrevUpHomeNext