Kea 2.7.6
|
Defines a thread pool which uses a thread pool queue for managing work items. More...
#include <thread_pool.h>
Public Types | |
typedef boost::shared_ptr< WorkItem > | WorkItemPtr |
Type of shared pointers to work items. | |
Public Member Functions | |
ThreadPool () | |
Constructor. | |
~ThreadPool () | |
Destructor. | |
bool | add (const WorkItemPtr &item) |
add a work item to the thread pool | |
bool | addFront (const WorkItemPtr &item) |
add a work item to the thread pool at front | |
size_t | count () |
count number of work items in the queue | |
bool | enabled () |
return the enable state of the queue | |
size_t | getMaxQueueSize () |
get maximum number of work items in the queue | |
double | getQueueStat (size_t which) |
get queue length statistic | |
void | pause (bool wait=true) |
pause threads | |
bool | paused () |
return the pause state of the queue | |
void | reset () |
reset the thread pool stopping threads and clearing the internal queue | |
void | resume () |
resume threads | |
void | setMaxQueueSize (size_t max_queue_size) |
set maximum number of work items in the queue | |
size_t | size () |
size number of thread pool threads | |
void | start (uint32_t thread_count) |
start all the threads | |
void | stop () |
stop all the threads | |
void | wait () |
wait for current items to be processed | |
bool | wait (uint32_t seconds) |
wait for items to be processed or return after timeout | |
Static Public Attributes | |
static const double | CEXP10 = std::exp(-.1) |
Rounding value for 10 packet statistic. | |
static const double | CEXP100 = std::exp(-.01) |
Rounding value for 100 packet statistic. | |
static const double | CEXP1000 = std::exp(-.001) |
Rounding value for 1000 packet statistic. | |
Defines a thread pool which uses a thread pool queue for managing work items.
Each work item is a 'functor' object.
WorkItem | a functor |
Container | a 'queue like' container |
Definition at line 34 of file thread_pool.h.
boost::shared_ptr<WorkItem> isc::util::ThreadPool< WorkItem, Container >::WorkItemPtr |
Type of shared pointers to work items.
Definition at line 45 of file thread_pool.h.
|
inline |
Constructor.
Definition at line 48 of file thread_pool.h.
|
inline |
Destructor.
Definition at line 52 of file thread_pool.h.
References isc::util::ThreadPool< WorkItem, Container >::reset().
|
inline |
add a work item to the thread pool
item | the 'functor' object to be added to the queue |
Definition at line 97 of file thread_pool.h.
Referenced by isc::dhcp::Dhcpv4Srv::processLocalizedQuery4(), isc::dhcp::Dhcpv6Srv::processLocalizedQuery6(), isc::dhcp::Dhcpv4Srv::selectSubnet(), isc::dhcp::Dhcpv6Srv::selectSubnet(), and isc::dhcp::Dhcpv4Srv::selectSubnet4o6().
|
inline |
add a work item to the thread pool at front
item | the 'functor' object to be added to the queue |
Definition at line 105 of file thread_pool.h.
Referenced by isc::dhcp::ClientHandler::~ClientHandler().
|
inline |
count number of work items in the queue
Definition at line 112 of file thread_pool.h.
|
inline |
return the enable state of the queue
The 'enabled' state corresponds to true value The 'disabled' state corresponds to false value
Definition at line 165 of file thread_pool.h.
Referenced by isc::util::MultiThreadingMgr::exitCriticalSection().
|
inline |
get maximum number of work items in the queue
Definition at line 189 of file thread_pool.h.
Referenced by isc::util::MultiThreadingMgr::getPacketQueueSize().
|
inline |
get queue length statistic
which | select the statistic (10, 100 or 1000) |
InvalidParameter | if which is not 10 and 100 and 1000. |
Definition at line 205 of file thread_pool.h.
|
inline |
pause threads
Used to pause threads so that they stop processing tasks
wait | the flag indicating if should wait for threads to pause. |
Definition at line 148 of file thread_pool.h.
References isc::util::ThreadPool< WorkItem, Container >::wait().
Referenced by isc::util::MultiThreadingMgr::enterCriticalSection().
|
inline |
return the pause state of the queue
The 'paused' state corresponds to true value The 'resumed' state corresponds to false value
Definition at line 175 of file thread_pool.h.
|
inline |
reset the thread pool stopping threads and clearing the internal queue
It can be called several times even when the thread pool is stopped
Definition at line 60 of file thread_pool.h.
Referenced by isc::util::ThreadPool< WorkItem, Container >::~ThreadPool(), and isc::util::MultiThreadingMgr::apply().
|
inline |
resume threads
Used to resume threads so that they start processing tasks
Definition at line 155 of file thread_pool.h.
Referenced by isc::util::MultiThreadingMgr::exitCriticalSection().
|
inline |
set maximum number of work items in the queue
max_queue_size | the maximum size (0 means unlimited) |
Definition at line 182 of file thread_pool.h.
Referenced by isc::util::MultiThreadingMgr::setPacketQueueSize().
|
inline |
size number of thread pool threads
Definition at line 196 of file thread_pool.h.
Referenced by isc::util::MultiThreadingMgr::apply().
|
inline |
start all the threads
thread_count | specifies the number of threads to be created and started |
InvalidOperation | if thread pool already started |
InvalidParameter | if thread count is 0 |
Definition at line 72 of file thread_pool.h.
References isc_throw.
Referenced by isc::util::MultiThreadingMgr::apply(), and isc::util::MultiThreadingMgr::exitCriticalSection().
|
inline |
stop all the threads
InvalidOperation | if thread pool already stopped |
Definition at line 85 of file thread_pool.h.
References isc_throw.
Referenced by isc::util::MultiThreadingMgr::apply().
|
inline |
wait for current items to be processed
Used to block the calling thread until all items in the queue have been processed
Definition at line 120 of file thread_pool.h.
References isc_throw.
Referenced by isc::util::ThreadPool< WorkItem, Container >::pause().
|
inline |
wait for items to be processed or return after timeout
Used to block the calling thread until all items in the queue have been processed or return after timeout
seconds | the time in seconds to wait for tasks to finish |
Definition at line 135 of file thread_pool.h.
References isc_throw.
|
static |
Rounding value for 10 packet statistic.
Initialize the 10 packet rounding to exp(-.1)
Definition at line 36 of file thread_pool.h.
|
static |
Rounding value for 100 packet statistic.
Initialize the 100 packet rounding to exp(-.01)
Definition at line 39 of file thread_pool.h.
|
static |
Rounding value for 1000 packet statistic.
Initialize the 1000 packet rounding to exp(-.001)
Definition at line 42 of file thread_pool.h.