Kea 2.5.8
isc::tcp::MtTcpListenerMgr Class Reference

Manages a thread-pool that is used to drive a TcpListener. More...

#include <mt_tcp_listener_mgr.h>

Public Member Functions

 MtTcpListenerMgr (TcpListenerFactory listener_factory, const asiolink::IOAddress &address, const uint16_t port, const uint16_t thread_pool_size=1, asiolink::TlsContextPtr context=asiolink::TlsContextPtr(), TcpConnectionFilterCallback connection_filter=0)
 Constructor.
 
virtual ~MtTcpListenerMgr ()
 Destructor.
 
void checkPermissions ()
 Check if the current thread can perform thread pool state transition.
 
isc::asiolink::IOAddress getAddress () const
 Fetches the IP address on which to listen.
 
long getIdleTimeout ()
 
uint16_t getPort () const
 Fetches the port number on which to listen.
 
const TcpListenerPtr getTcpListener ()
 Fetch a pointer to the listener.
 
uint16_t getThreadCount () const
 Fetches the number of threads in the pool.
 
asiolink::IOServicePtr getThreadIOService () const
 Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode.
 
uint16_t getThreadPoolSize () const
 Fetches the maximum size of the thread pool.
 
asiolink::TlsContextPtr getTlsContext () const
 Fetches the TLS context.
 
bool isPaused ()
 Indicates if the thread pool is paused.
 
bool isRunning ()
 Indicates if the thread pool is running.
 
bool isStopped ()
 Indicates if the thread pool is stopped.
 
void pause ()
 Pauses the listener's thread pool.
 
void resume ()
 Resumes running the listener's thread pool.
 
void setIdleTimeout (long milliseconds)
 Sets the idle time per connection.
 
void start ()
 Starts running the listener's thread pool.
 
void stop ()
 Stops the listener's thread pool.
 

Detailed Description

Manages a thread-pool that is used to drive a TcpListener.

This class manages an IOServiceThreadPool which in turn is used to drive an internal instance of TcpListener. This allows the listener connections to each run on their own thread within the pool. The pool can be started, paused, resumed, and stopped.

Note
This class is NOT compatible with Kea core single-threading. It is incumbent upon the owner to ensure the Kea core multi-threading is (or will be) enabled when creating instances of this class.

Definition at line 43 of file mt_tcp_listener_mgr.h.

Constructor & Destructor Documentation

◆ MtTcpListenerMgr()

isc::tcp::MtTcpListenerMgr::MtTcpListenerMgr ( TcpListenerFactory  listener_factory,
const asiolink::IOAddress address,
const uint16_t  port,
const uint16_t  thread_pool_size = 1,
asiolink::TlsContextPtr  context = asiolink::TlsContextPtr(),
TcpConnectionFilterCallback  connection_filter = 0 
)

Constructor.

Parameters
listener_factoryFunction for instantiating the internal TcpListener
addressIp address to listen on for connections
portIp port to listen on for connections
thread_pool_sizeMaximum Number of threads in the thread pool. This implicit dictates the maximum number of connections.
contextTLS context for authenticating connections. Defaults to empty.
connection_filterCallback connections may use to filter connections by their remote endpoint characteristics (e.g. ip address)

Definition at line 25 of file mt_tcp_listener_mgr.cc.

◆ ~MtTcpListenerMgr()

isc::tcp::MtTcpListenerMgr::~MtTcpListenerMgr ( )
virtual

Destructor.

Definition at line 37 of file mt_tcp_listener_mgr.cc.

References stop().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkPermissions()

void isc::tcp::MtTcpListenerMgr::checkPermissions ( )

Check if the current thread can perform thread pool state transition.

Exceptions
MultiThreadingInvalidOperationif the state transition is done on any of the worker threads.

Definition at line 114 of file mt_tcp_listener_mgr.cc.

◆ getAddress()

isc::asiolink::IOAddress isc::tcp::MtTcpListenerMgr::getAddress ( ) const
inline

Fetches the IP address on which to listen.

Returns
IOAddress containing the address on which to listen.

Definition at line 111 of file mt_tcp_listener_mgr.h.

◆ getIdleTimeout()

long isc::tcp::MtTcpListenerMgr::getIdleTimeout ( )
inline

Definition at line 168 of file mt_tcp_listener_mgr.h.

References isc::tcp::TcpListener::IdleTimeout::value_.

◆ getPort()

uint16_t isc::tcp::MtTcpListenerMgr::getPort ( ) const
inline

Fetches the port number on which to listen.

Returns
uint16_t containing the port number on which to listen.

Definition at line 118 of file mt_tcp_listener_mgr.h.

◆ getTcpListener()

const TcpListenerPtr isc::tcp::MtTcpListenerMgr::getTcpListener ( )
inline

Fetch a pointer to the listener.

Definition at line 157 of file mt_tcp_listener_mgr.h.

◆ getThreadCount()

uint16_t isc::tcp::MtTcpListenerMgr::getThreadCount ( ) const
inline

Fetches the number of threads in the pool.

Returns
uint16_t containing the number of running threads.

Definition at line 139 of file mt_tcp_listener_mgr.h.

◆ getThreadIOService()

asiolink::IOServicePtr isc::tcp::MtTcpListenerMgr::getThreadIOService ( ) const
inline

Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode.

Returns
pointer to the IOService instance, or an empty pointer in single-threaded mode.

Definition at line 152 of file mt_tcp_listener_mgr.h.

◆ getThreadPoolSize()

uint16_t isc::tcp::MtTcpListenerMgr::getThreadPoolSize ( ) const
inline

Fetches the maximum size of the thread pool.

Returns
uint16_t containing the maximum size of the thread pool.

Definition at line 125 of file mt_tcp_listener_mgr.h.

◆ getTlsContext()

asiolink::TlsContextPtr isc::tcp::MtTcpListenerMgr::getTlsContext ( ) const
inline

Fetches the TLS context.

Returns
TLS context.

Definition at line 132 of file mt_tcp_listener_mgr.h.

◆ isPaused()

bool isc::tcp::MtTcpListenerMgr::isPaused ( )

Indicates if the thread pool is paused.

Returns
True if the thread pool exists and it is in the PAUSED state, false otherwise.

Definition at line 192 of file mt_tcp_listener_mgr.cc.

◆ isRunning()

bool isc::tcp::MtTcpListenerMgr::isRunning ( )

Indicates if the thread pool is running.

Returns
True if the thread pool exists and it is in the RUNNING state, false otherwise.

Definition at line 174 of file mt_tcp_listener_mgr.cc.

◆ isStopped()

bool isc::tcp::MtTcpListenerMgr::isStopped ( )

Indicates if the thread pool is stopped.

Returns
True if the thread pool does not exist or it is in the STOPPED state, false otherwise.

Definition at line 183 of file mt_tcp_listener_mgr.cc.

Referenced by start().

◆ pause()

void isc::tcp::MtTcpListenerMgr::pause ( )

Pauses the listener's thread pool.

Suspends thread pool event processing.

Definition at line 121 of file mt_tcp_listener_mgr.cc.

◆ resume()

void isc::tcp::MtTcpListenerMgr::resume ( )

Resumes running the listener's thread pool.

Resumes thread pool event processing.

Definition at line 128 of file mt_tcp_listener_mgr.cc.

◆ setIdleTimeout()

void isc::tcp::MtTcpListenerMgr::setIdleTimeout ( long  milliseconds)
inline

Sets the idle time per connection.

Parameters
millisecondsAmount of time in milliseconds

Definition at line 164 of file mt_tcp_listener_mgr.h.

◆ start()

void isc::tcp::MtTcpListenerMgr::start ( )

Starts running the listener's thread pool.

Definition at line 42 of file mt_tcp_listener_mgr.cc.

References isc::log::DBGLVL_TRACE_BASIC, isc::util::MultiThreadingMgr::instance(), isc_throw, isStopped(), LOG_DEBUG, isc::tcp::MT_TCP_LISTENER_MGR_STARTED, isc::tcp::tcp_logger, and isc::Exception::what().

+ Here is the call graph for this function:

◆ stop()

void isc::tcp::MtTcpListenerMgr::stop ( )

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