7#ifndef IOSERVICE_THREAD_POOL_H
8#define IOSERVICE_THREAD_POOL_H
13#include <boost/shared_ptr.hpp>
15#include <condition_variable>
44 bool defer_start =
false);
117 void checkPermissions(
State state);
122 bool checkThreadId(std::thread::id
id);
158 void setState(
State state);
170 bool validateStateChange(
State state)
const;
176 static std::string stateToText(
State state);
239 std::condition_variable thread_cv_;
243 std::condition_variable main_cv_;
256 std::list<boost::shared_ptr<std::thread> > threads_;
Implements a pausable pool of IOService driven threads.
asiolink::IOServicePtr getIOService() const
Fetches the IOService that drives the pool.
void checkPausePermissions()
Check current thread permissions to transition to the new PAUSED state.
uint16_t getPoolSize() const
Fetches the maximum size of the thread pool.
~IoServiceThreadPool()
Destructor.
void stop()
Transitions the pool from RUNNING or PAUSED to STOPPED.
void pause()
Transitions the pool from RUNNING to PAUSED.
IoServiceThreadPool(asiolink::IOServicePtr io_service, size_t pool_size, bool defer_start=false)
Constructor.
bool isPaused()
Check if the thread pool is paused.
bool isStopped()
Check if the thread pool is stopped.
void run()
Transitions the pool from STOPPED or PAUSED to RUNNING.
uint16_t getThreadCount() const
Fetches the number of threads in the pool.
State
Describes the possible operational state of the thread pool.
@ RUNNING
Pool is not operational.
@ PAUSED
Pool is populated with running threads.
bool isRunning()
Check if the thread pool is running.
A wrapper interface for the ASIO library.
boost::shared_ptr< IoServiceThreadPool > IoServiceThreadPoolPtr
Defines a pointer to a thread pool.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Defines the logger used by the top-level component of kea-lfc.