Kea
1.9.9-git
|
Implements a pausable pool of IOService driven threads. More...
#include <http_thread_pool.h>
Public Types | |
enum | State { State::STOPPED, State::RUNNING, State::PAUSED } |
Describes the possible operational state of the thread pool. More... | |
Public Member Functions | |
HttpThreadPool (asiolink::IOServicePtr io_service, size_t pool_size, bool defer_start=false) | |
Constructor. More... | |
~HttpThreadPool () | |
Destructor. More... | |
asiolink::IOServicePtr | getIOService () const |
Fetches the IOService that drives the pool. More... | |
uint16_t | getPoolSize () const |
Fetches the maximum size of the thread pool. More... | |
uint16_t | getThreadCount () const |
Fetches the number of threads in the pool. More... | |
bool | isPaused () |
Check if the thread pool is paused. More... | |
bool | isRunning () |
Check if the thread pool is running. More... | |
bool | isStopped () |
Check if the thread pool is stopped. More... | |
void | pause () |
Transitions the pool from RUNNING to PAUSED. More... | |
void | run () |
Transitions the pool from STOPPED or PAUSED to RUNNING. More... | |
void | stop () |
Transitions the pool from RUNNING or PAUSED to STOPPED. More... | |
Implements a pausable pool of IOService driven threads.
Definition at line 24 of file http_thread_pool.h.
|
strong |
Describes the possible operational state of the thread pool.
Enumerator | |
---|---|
STOPPED | |
RUNNING |
Pool is not operational. |
PAUSED |
Pool is populated with running threads. |
Definition at line 27 of file http_thread_pool.h.
HttpThreadPool::HttpThreadPool | ( | asiolink::IOServicePtr | io_service, |
size_t | pool_size, | ||
bool | defer_start = false |
||
) |
Constructor.
io_service | IOService that will drive the pool's IO. If empty, it create it's own instance. |
pool_size | Maximum number of threads in the pool. Currently the number of threads is fixed at this value. |
defer_start | If true, creation of the threads is deferred until a subsequent call to start(). In this case the pool's operational state post construction is STOPPED. If false, the constructor will invoke run() to transition the pool into the RUNNING state. |
Definition at line 33 of file http_thread_pool.cc.
References isc_throw, and run().
HttpThreadPool::~HttpThreadPool | ( | ) |
Destructor.
Ensures the thread pool is stopped prior to destruction.
Definition at line 53 of file http_thread_pool.cc.
References stop().
IOServicePtr HttpThreadPool::getIOService | ( | ) | const |
Fetches the IOService that drives the pool.
Definition at line 229 of file http_thread_pool.cc.
uint16_t HttpThreadPool::getPoolSize | ( | ) | const |
Fetches the maximum size of the thread pool.
Definition at line 234 of file http_thread_pool.cc.
uint16_t HttpThreadPool::getThreadCount | ( | ) | const |
Fetches the number of threads in the pool.
Definition at line 239 of file http_thread_pool.cc.
|
inline |
Check if the thread pool is paused.
Definition at line 84 of file http_thread_pool.h.
References PAUSED.
|
inline |
Check if the thread pool is running.
Definition at line 77 of file http_thread_pool.h.
References RUNNING.
|
inline |
Check if the thread pool is stopped.
Definition at line 91 of file http_thread_pool.h.
References STOPPED.
void HttpThreadPool::pause | ( | ) |
Transitions the pool from RUNNING to PAUSED.
Pool threads suspend event processing and pause until they are released to either resume running or stop. Has no effect if the pool is already in the PAUSED or STOPPED state.
Definition at line 63 of file http_thread_pool.cc.
References PAUSED.
void HttpThreadPool::run | ( | ) |
Transitions the pool from STOPPED or PAUSED to RUNNING.
When called from the STOPPED state, the pool threads are created and begin processing events. When called from the PAUSED state, the pool threads are released from PAUSED and resume processing events. Has no effect if the pool is already in the RUNNING state.
Definition at line 58 of file http_thread_pool.cc.
References RUNNING.
Referenced by HttpThreadPool().
void HttpThreadPool::stop | ( | ) |
Transitions the pool from RUNNING or PAUSED to STOPPED.
Stops thread event processing and then destroys the pool's threads Has no effect if the pool is already in the STOPPED state.
Definition at line 68 of file http_thread_pool.cc.
References STOPPED.
Referenced by ~HttpThreadPool().