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

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

#include <IoContextThreadGroup.h>

Public Member Functions

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

Private Attributes

boost_iocontext_t m_ioContext
 Boost ASIO I/O context.
 
boost::asio::executor_work_guard< boost::asio::io_context::executor_type > m_ioWorkGuard
 Boost ASIO I/O context work guard object.
 
threads::ThreadGroup m_threadGroup
 Our thread group.
 

Detailed Description

I/O Context Thread group class.

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

Constructor & Destructor Documentation

◆ IoContextThreadGroup()

core_lib::asio::IoContextThreadGroup::IoContextThreadGroup ( 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

◆ IoContext()

boost_iocontext_t & core_lib::asio::IoContextThreadGroup::IoContext ( )

Get the I/O context.

Returns
A reference to the I/O context.

◆ Post()

template<typename F >
void core_lib::asio::IoContextThreadGroup::Post ( F &&  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: