MySQL 8.0.39
Source Code Documentation
ConnectionPool Class Reference

connection pool of mysql connections. More...

#include <connection_pool.h>

Public Types

using connection_type = PooledClassicConnection
 

Public Member Functions

 ConnectionPool (uint32_t max_pooled_connections, std::chrono::milliseconds idle_timeout)
 
 ConnectionPool (const ConnectionPool &)=delete
 
ConnectionPooloperator= (const ConnectionPool &)=delete
 
 ConnectionPool (ConnectionPool &&)=delete
 
ConnectionPooloperator= (ConnectionPool &&)=delete
 
 ~ConnectionPool ()=default
 
void add (connection_type conn)
 
std::optional< connection_typeadd_if_not_full (connection_type conn)
 add connection to the pool if the poll isn't full. More...
 
template<class UnaryPredicate >
std::optional< connection_typepop_if (UnaryPredicate pred)
 get a connection from the pool that matches a predicate. More...
 
uint32_t current_pooled_connections () const
 number of currently pooled connections. More...
 
uint32_t max_pooled_connections () const
 
std::chrono::milliseconds idle_timeout () const
 
uint64_t reused_connections () const
 total number of reused connections. More...
 

Protected Types

using container_type = std::list< connection_type >
 

Protected Member Functions

void erase (container_type::iterator it)
 

Protected Attributes

const uint32_t max_pooled_connections_
 
const std::chrono::milliseconds idle_timeout_
 
Monitor< std::list< connection_type > > pool_ {{}}
 
uint64_t reused_ {}
 

Detailed Description

connection pool of mysql connections.

pool can contain connections:

  • of any protocol.
  • to any tcp endpoint.

Member Typedef Documentation

◆ connection_type

◆ container_type

using ConnectionPool::container_type = std::list<connection_type>
protected

Constructor & Destructor Documentation

◆ ConnectionPool() [1/3]

ConnectionPool::ConnectionPool ( uint32_t  max_pooled_connections,
std::chrono::milliseconds  idle_timeout 
)
inline

◆ ConnectionPool() [2/3]

ConnectionPool::ConnectionPool ( const ConnectionPool )
delete

◆ ConnectionPool() [3/3]

ConnectionPool::ConnectionPool ( ConnectionPool &&  )
delete

◆ ~ConnectionPool()

ConnectionPool::~ConnectionPool ( )
default

Member Function Documentation

◆ add()

void ConnectionPool::add ( ConnectionPool::connection_type  conn)

◆ add_if_not_full()

std::optional< ConnectionPool::connection_type > ConnectionPool::add_if_not_full ( ConnectionPool::connection_type  conn)

add connection to the pool if the poll isn't full.

◆ current_pooled_connections()

uint32_t ConnectionPool::current_pooled_connections ( ) const

number of currently pooled connections.

◆ erase()

void ConnectionPool::erase ( container_type::iterator  it)
protected

◆ idle_timeout()

std::chrono::milliseconds ConnectionPool::idle_timeout ( ) const
inline

◆ max_pooled_connections()

uint32_t ConnectionPool::max_pooled_connections ( ) const
inline

◆ operator=() [1/2]

ConnectionPool & ConnectionPool::operator= ( ConnectionPool &&  )
delete

◆ operator=() [2/2]

ConnectionPool & ConnectionPool::operator= ( const ConnectionPool )
delete

◆ pop_if()

template<class UnaryPredicate >
std::optional< connection_type > ConnectionPool::pop_if ( UnaryPredicate  pred)
inline

get a connection from the pool that matches a predicate.

Returns
a connection if one exists.

◆ reused_connections()

uint64_t ConnectionPool::reused_connections ( ) const
inline

total number of reused connections.

Member Data Documentation

◆ idle_timeout_

const std::chrono::milliseconds ConnectionPool::idle_timeout_
protected

◆ max_pooled_connections_

const uint32_t ConnectionPool::max_pooled_connections_
protected

◆ pool_

Monitor<std::list<connection_type> > ConnectionPool::pool_ {{}}
protected

◆ reused_

uint64_t ConnectionPool::reused_ {}
protected

The documentation for this class was generated from the following files: