MySQL 8.4.2
Source Code Documentation
|
connection pool of mysql connections. More...
#include <connection_pool.h>
Classes | |
struct | Stashed |
connection on the stash. More... | |
Public Types | |
using | ServerSideConnection = TlsSwitchableConnection< ServerSideClassicProtocolState > |
using | connection_type = PooledConnection< ServerSideConnection > |
using | ConnectionIdentifier = void * |
Public Member Functions | |
ConnectionPool (uint32_t max_pooled_connections, std::chrono::milliseconds idle_timeout) | |
ConnectionPool (const ConnectionPool &)=delete | |
ConnectionPool & | operator= (const ConnectionPool &)=delete |
ConnectionPool (ConnectionPool &&)=delete | |
ConnectionPool & | operator= (ConnectionPool &&)=delete |
~ConnectionPool ()=default | |
void | add (ServerSideConnection conn) |
add a connection to the pool. More... | |
std::optional< ServerSideConnection > | add_if_not_full (ServerSideConnection conn) |
add connection to the pool if the poll isn't full. More... | |
std::optional< ServerSideConnection > | pop_if (const std::string &ep, std::predicate< const ServerSideConnection & > auto 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 |
void | stash (ServerSideConnection conn, ConnectionIdentifier from, std::chrono::milliseconds delay) |
add a server-side connection to the stash. More... | |
void | discard_all_stashed (ConnectionIdentifier from) |
std::optional< ServerSideConnection > | unstash_if (const std::string &ep, std::function< bool(const ServerSideConnection &)> pred, bool ignore_sharing_delay=false) |
std::optional< ServerSideConnection > | unstash_mine (const std::string &ep, ConnectionIdentifier conn_id) |
size_t | current_stashed_connections () const |
number of server-side connections on the stash. More... | |
uint64_t | reused_connections () const |
total number of reused connections. More... | |
Protected Types | |
using | pool_type = std::unordered_multimap< std::string, PooledConnection< ServerSideConnection > > |
using | stash_type = std::unordered_multimap< std::string, Stashed > |
Protected Member Functions | |
void | erase (pool_type::iterator it) |
void | erase_from_stash (stash_type::iterator it) |
Protected Attributes | |
const uint32_t | max_pooled_connections_ |
const std::chrono::milliseconds | idle_timeout_ |
Monitor< pool_type > | pool_ {{}} |
Monitor< stash_type > | stash_ {{}} |
uint64_t | reused_ {} |
connection pool of mysql connections.
It can contain connections:
It has:
using ConnectionPool::ConnectionIdentifier = void * |
|
protected |
using ConnectionPool::ServerSideConnection = TlsSwitchableConnection<ServerSideClassicProtocolState> |
|
protected |
|
inline |
|
delete |
|
delete |
|
default |
void ConnectionPool::add | ( | ConnectionPool::ServerSideConnection | conn | ) |
add a connection to the pool.
if the pool is full, the connection will be close.
std::optional< ConnectionPool::ServerSideConnection > ConnectionPool::add_if_not_full | ( | ConnectionPool::ServerSideConnection | conn | ) |
add connection to the pool if the poll isn't full.
uint32_t ConnectionPool::current_pooled_connections | ( | ) | const |
number of currently pooled connections.
size_t ConnectionPool::current_stashed_connections | ( | ) | const |
number of server-side connections on the stash.
void ConnectionPool::discard_all_stashed | ( | ConnectionIdentifier | from | ) |
|
protected |
|
protected |
|
inline |
|
inline |
|
delete |
|
delete |
|
inline |
get a connection from the pool that matches a predicate.
|
inline |
total number of reused connections.
void ConnectionPool::stash | ( | ServerSideConnection | conn, |
ConnectionIdentifier | from, | ||
std::chrono::milliseconds | delay | ||
) |
add a server-side connection to the stash.
conn | server-side connection to be stashed. |
from | opaque connection-identifier |
delay | allow sharing with other connection after 'delay' milliseconds. |
std::optional< ConnectionPool::ServerSideConnection > ConnectionPool::unstash_if | ( | const std::string & | ep, |
std::function< bool(const ServerSideConnection &)> | pred, | ||
bool | ignore_sharing_delay = false |
||
) |
std::optional< ConnectionPool::ServerSideConnection > ConnectionPool::unstash_mine | ( | const std::string & | ep, |
ConnectionIdentifier | conn_id | ||
) |
|
protected |
|
protected |
|
protected |
|
protected |