MySQL 9.4.0
Source Code Documentation
PooledConnection< T > Class Template Reference

pooled connection. More...

#include <connection_pool.h>

Public Types

using Ssl = mysql_harness::Ssl
 
using connection_type = T
 

Public Member Functions

 PooledConnection (connection_type conn)
 
connection_typeconnection ()
 access to conn_. More...
 
const connection_typeconnection () const
 
connection_type release ()
 
void reset ()
 prepares for reusing the connection. More...
 
void pool_remover (std::function< void(std::shared_ptr< PooledConnection< T > >)> remover)
 set a remove-callback. More...
 

Static Public Member Functions

static void remove_from_pool (std::shared_ptr< PooledConnection< T > > shared_this)
 calls remove-callback. More...
 

Protected Member Functions

std::mutex & mtx ()
 

Protected Attributes

std::function< void(std::shared_ptr< PooledConnection< T > >)> pool_remover_
 

Static Private Member Functions

static void async_idle (std::shared_ptr< PooledConnection< T > > shared_this, std::chrono::milliseconds idle_timeout)
 wait for idle timeout. More...
 
static void async_recv_message (std::shared_ptr< PooledConnection< T > > shared_this)
 wait for server message and shutdown. More...
 

Private Attributes

std::mutex mtx_
 
connection_type conn_
 
net::steady_timer idle_timer_
 

Friends

class ConnectionPool
 

Detailed Description

template<class T>
class PooledConnection< T >

pooled connection.

Member Typedef Documentation

◆ connection_type

template<class T >
using PooledConnection< T >::connection_type = T

◆ Ssl

template<class T >
using PooledConnection< T >::Ssl = mysql_harness::Ssl

Constructor & Destructor Documentation

◆ PooledConnection()

template<class T >
PooledConnection< T >::PooledConnection ( connection_type  conn)
inline

Member Function Documentation

◆ async_idle()

template<class T >
static void PooledConnection< T >::async_idle ( std::shared_ptr< PooledConnection< T > >  shared_this,
std::chrono::milliseconds  idle_timeout 
)
inlinestaticprivate

wait for idle timeout.

◆ async_recv_message()

template<class T >
static void PooledConnection< T >::async_recv_message ( std::shared_ptr< PooledConnection< T > >  shared_this)
inlinestaticprivate

wait for server message and shutdown.

◆ connection() [1/2]

template<class T >
connection_type & PooledConnection< T >::connection ( )
inline

access to conn_.

allows others to move the connection structs out.

◆ connection() [2/2]

template<class T >
const connection_type & PooledConnection< T >::connection ( ) const
inline

◆ mtx()

template<class T >
std::mutex & PooledConnection< T >::mtx ( )
inlineprotected

◆ pool_remover()

template<class T >
void PooledConnection< T >::pool_remover ( std::function< void(std::shared_ptr< PooledConnection< T > >)>  remover)
inline

set a remove-callback.

used when the pooled connection wants to remove itself from the connection-pool.

◆ release()

template<class T >
connection_type PooledConnection< T >::release ( )
inline

◆ remove_from_pool()

template<class T >
static void PooledConnection< T >::remove_from_pool ( std::shared_ptr< PooledConnection< T > >  shared_this)
inlinestatic

calls remove-callback.

◆ reset()

template<class T >
void PooledConnection< T >::reset ( )
inline

prepares for reusing the connection.

Friends And Related Function Documentation

◆ ConnectionPool

template<class T >
friend class ConnectionPool
friend

Member Data Documentation

◆ conn_

template<class T >
connection_type PooledConnection< T >::conn_
private

◆ idle_timer_

template<class T >
net::steady_timer PooledConnection< T >::idle_timer_
private

◆ mtx_

template<class T >
std::mutex PooledConnection< T >::mtx_
private

◆ pool_remover_

template<class T >
std::function<void(std::shared_ptr<PooledConnection<T>>)> PooledConnection< T >::pool_remover_
protected

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