7 #ifndef MULTI_THREADING_MGR_H
8 #define MULTI_THREADING_MGR_H
14 #include <boost/noncopyable.hpp>
39 const Callback& exit_cb)
89 std::list<CSCallbackPair> cb_pairs_;
203 void apply(
bool enabled, uint32_t thread_count, uint32_t queue_size);
250 void stopProcessing();
261 void startProcessing();
275 uint32_t critical_section_count_;
278 uint32_t thread_pool_size_;
318 #endif // MULTI_THREADING_MGR_H
RAII class creating a critical section.
CSCallbackPairList()
Constructor.
Maintains list of unique CSCallbackPairs.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
MultiThreadingMgr()
Constructor.
MultiThreadingCriticalSection()
Constructor.
uint32_t getThreadPoolSize() const
Get the configured dhcp thread pool size.
void removeAllCriticalSectionCallbacks()
Removes all callbacks in the list of CriticalSection callbacks.
void enterCriticalSection()
Enter critical section.
void exitCriticalSection()
Exit critical section.
void setThreadPoolSize(uint32_t size)
Set the configured dhcp thread pool size.
std::function< void()> Callback
Defines a callback as a simple void() functor.
void setMode(bool enabled)
Set the multi-threading mode.
bool getMode() const
Get the multi-threading mode.
void removeAll()
Removes all callbacks from the list.
const std::list< CSCallbackPair > & getCallbackPairs()
Fetches the list of callback pairs.
void addCallbackPair(const std::string &name, const CSCallbackPair::Callback &entry_cb, const CSCallbackPair::Callback &exit_cb)
Adds a callback pair to the list.
void addCriticalSectionCallbacks(const std::string &name, const CSCallbackPair::Callback &entry_cb, const CSCallbackPair::Callback &exit_cb)
Adds a pair of callbacks to the list of CriticalSection callbacks.
virtual ~MultiThreadingMgr()
Destructor.
void setPacketQueueSize(uint32_t size)
Set the configured dhcp packet queue size.
Callback entry_cb_
Entry point callback associated with name.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual ~MultiThreadingCriticalSection()
Destructor.
CSCallbackPair(const std::string &name, const Callback &entry_cb, const Callback &exit_cb)
Constructor.
Callback exit_cb_
Exit point callback associated with name.
ThreadPool< std::function< void()> > & getThreadPool()
Get the dhcp thread pool.
void removeCriticalSectionCallbacks(const std::string &name)
Removes the set of callbacks associated with a given name from the list of CriticalSection callbacks...
void removeCallbackPair(const std::string &name)
Removes a callback pair from the list.
bool isInCriticalSection()
Is in critical section flag.
Defines a thread pool which uses a thread pool queue for managing work items.
static uint32_t detectThreadCount()
The system current detected hardware concurrency thread count.
uint32_t getPacketQueueSize()
Get the configured dhcp packet queue size.
void apply(bool enabled, uint32_t thread_count, uint32_t queue_size)
Apply the multi-threading related settings.
std::string name_
Name by which the callback can be found.
Embodies a named pair of CriticalSection callbacks.