te::common::ThreadGroup Class Reference

This class represents a thread group. More...

#include <ThreadGroup.h>

Public Member Functions

template<typename Function >
void addJob (Function func)
 Waits for all threads to finish their jobs. More...
 
std::size_t getThreadCount ()
 Creates a new job and binds it to the given function. Use std::bind(function, object, params...) as argument. More...
 
 ThreadGroup (std::size_t threadCount=0)
 < Constructor. If the given thread count is 0, it will detect and use all available threads More...
 
void waitToFinish ()
 
 ~ThreadGroup ()
 Gets the number of threads that are defined to be used by this class. More...
 

Private Member Functions

void run ()
 < Starts the execution of the thread group. Note that the jobs must be added before the calling of this function More...
 

Private Attributes

std::unique_ptr< boost::asio::io_service > m_ioService
 Boost IO service. More...
 
std::size_t m_threadCount
 
std::unique_ptr< boost::thread_group > m_threadGroup
 Boost thread group. More...
 
std::unique_ptr< boost::asio::io_service::work > m_work
 Boost work. More...
 

Detailed Description

This class represents a thread group.

Definition at line 50 of file ThreadGroup.h.

Constructor & Destructor Documentation

◆ ThreadGroup()

te::common::ThreadGroup::ThreadGroup ( std::size_t  threadCount = 0)

< Constructor. If the given thread count is 0, it will detect and use all available threads

Destructor

◆ ~ThreadGroup()

te::common::ThreadGroup::~ThreadGroup ( )

Gets the number of threads that are defined to be used by this class.

Member Function Documentation

◆ addJob()

template<typename Function >
void te::common::ThreadGroup::addJob ( Function  func)

Waits for all threads to finish their jobs.

Definition at line 85 of file ThreadGroup.h.

References m_ioService.

◆ getThreadCount()

std::size_t te::common::ThreadGroup::getThreadCount ( )

Creates a new job and binds it to the given function. Use std::bind(function, object, params...) as argument.

◆ run()

void te::common::ThreadGroup::run ( )
private

< Starts the execution of the thread group. Note that the jobs must be added before the calling of this function

◆ waitToFinish()

void te::common::ThreadGroup::waitToFinish ( )

Member Data Documentation

◆ m_ioService

std::unique_ptr<boost::asio::io_service> te::common::ThreadGroup::m_ioService
private

Boost IO service.

Definition at line 78 of file ThreadGroup.h.

Referenced by addJob().

◆ m_threadCount

std::size_t te::common::ThreadGroup::m_threadCount
private

Definition at line 77 of file ThreadGroup.h.

◆ m_threadGroup

std::unique_ptr<boost::thread_group> te::common::ThreadGroup::m_threadGroup
private

Boost thread group.

Definition at line 79 of file ThreadGroup.h.

◆ m_work

std::unique_ptr<boost::asio::io_service::work> te::common::ThreadGroup::m_work
private

Boost work.

Definition at line 80 of file ThreadGroup.h.


The documentation for this class was generated from the following file: