Core Library  1.6.0.0
Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.
core_lib::asio::IoServiceThreadGroup Class Referencefinal

I/O Service Thread group class. More...

#include <IoServiceThreadGroup.h>

Public Member Functions

 IoServiceThreadGroup (unsigned int numThreads=std::thread::hardware_concurrency())
 Initialising constuctor. More...
 
 IoServiceThreadGroup (const IoServiceThreadGroup &)=delete
 Copy constructor deleted.
 
IoServiceThreadGroupoperator= (const IoServiceThreadGroup &)=delete
 Copy assignment operator deleted.
 
 IoServiceThreadGroup (IoServiceThreadGroup &&)=delete
 Move constructor deleted.
 
IoServiceThreadGroupoperator= (IoServiceThreadGroup &&)=delete
 Move assignment operator deleted.
 
 ~IoServiceThreadGroup ()
 Destructor.
 
boost_ioservice_tIoService ()
 Get the I/O service. More...
 
template<typename F >
void Post (F function)
 Post a function object to be run by one of our threads. More...
 

Private Attributes

boost_ioservice_t m_ioService
 Boost ASIO I/O service.
 
boost_ioservice_t::work m_ioWork
 Boost ASIO I/O service work object.
 
threads::ThreadGroup m_threadGroup
 Our thread group.
 

Detailed Description

I/O Service Thread group class.

This class implements a thread group mechanism for use by Boost's ASIO I/O service. This allows the I/O Service to spread its work load across multiple threads. This class also calls run on the I/O service from each registered thread and also calls stop and joins all threads in its destructor.

Constructor & Destructor Documentation

◆ IoServiceThreadGroup()

core_lib::asio::IoServiceThreadGroup::IoServiceThreadGroup ( unsigned int  numThreads = std::thread::hardware_concurrency())
explicit

Initialising constuctor.

Parameters
[in]numThreads- (Optional) Number of threads to create.

If the number of threads is not specified then the value will be assigned using std::thread::hardware_concurrency().

Member Function Documentation

◆ IoService()

boost_ioservice_t & core_lib::asio::IoServiceThreadGroup::IoService ( )

Get the I/O service.

Returns
A reference to the I/O service.

◆ Post()

template<typename F >
void core_lib::asio::IoServiceThreadGroup::Post ( function)
inline

Post a function object to be run by one of our threads.

Parameters
[in]function- Function to be run by one of our threads.

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