Kea 2.7.5
|
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. | |
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.
Definition at line 43 of file mt_tcp_listener_mgr.h.
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.
listener_factory | Function for instantiating the internal TcpListener |
address | Ip address to listen on for connections |
port | Ip port to listen on for connections |
thread_pool_size | Maximum Number of threads in the thread pool. This implicit dictates the maximum number of connections. |
context | TLS context for authenticating connections. Defaults to empty. |
connection_filter | Callback 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.
|
virtual |
Destructor.
Definition at line 37 of file mt_tcp_listener_mgr.cc.
References stop().
void isc::tcp::MtTcpListenerMgr::checkPermissions | ( | ) |
Check if the current thread can perform thread pool state transition.
MultiThreadingInvalidOperation | if the state transition is done on any of the worker threads. |
Definition at line 112 of file mt_tcp_listener_mgr.cc.
|
inline |
Fetches the IP address on which to listen.
Definition at line 111 of file mt_tcp_listener_mgr.h.
|
inline |
Definition at line 168 of file mt_tcp_listener_mgr.h.
References isc::tcp::TcpListener::IdleTimeout::value_.
|
inline |
Fetches the port number on which to listen.
Definition at line 118 of file mt_tcp_listener_mgr.h.
|
inline |
Fetch a pointer to the listener.
Definition at line 157 of file mt_tcp_listener_mgr.h.
|
inline |
Fetches the number of threads in the pool.
Definition at line 139 of file mt_tcp_listener_mgr.h.
|
inline |
Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode.
Definition at line 152 of file mt_tcp_listener_mgr.h.
|
inline |
Fetches the maximum size of the thread pool.
Definition at line 125 of file mt_tcp_listener_mgr.h.
|
inline |
bool isc::tcp::MtTcpListenerMgr::isPaused | ( | ) |
Indicates if the thread pool is paused.
Definition at line 185 of file mt_tcp_listener_mgr.cc.
bool isc::tcp::MtTcpListenerMgr::isRunning | ( | ) |
Indicates if the thread pool is running.
Definition at line 167 of file mt_tcp_listener_mgr.cc.
bool isc::tcp::MtTcpListenerMgr::isStopped | ( | ) |
Indicates if the thread pool is stopped.
Definition at line 176 of file mt_tcp_listener_mgr.cc.
Referenced by start().
void isc::tcp::MtTcpListenerMgr::pause | ( | ) |
Pauses the listener's thread pool.
Suspends thread pool event processing.
Definition at line 119 of file mt_tcp_listener_mgr.cc.
void isc::tcp::MtTcpListenerMgr::resume | ( | ) |
Resumes running the listener's thread pool.
Resumes thread pool event processing.
Definition at line 126 of file mt_tcp_listener_mgr.cc.
|
inline |
Sets the idle time per connection.
milliseconds | Amount of time in milliseconds |
Definition at line 164 of file mt_tcp_listener_mgr.h.
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().
void isc::tcp::MtTcpListenerMgr::stop | ( | ) |
Stops the listener's thread pool.
Definition at line 133 of file mt_tcp_listener_mgr.cc.
References isc::log::DBGLVL_TRACE_BASIC, LOG_DEBUG, isc::tcp::MT_TCP_LISTENER_MGR_STOPPED, isc::tcp::MT_TCP_LISTENER_MGR_STOPPING, and isc::tcp::tcp_logger.
Referenced by ~MtTcpListenerMgr().