PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::AsioIoContextRunner Class Reference

Keeps an Asio I/O context running on a dedicated worker thread. More...

#include <AsioIoContextRunner.h>

+ Inheritance diagram for profinet::AsioIoContextRunner:
+ Collaboration diagram for profinet::AsioIoContextRunner:

Public Member Functions

 AsioIoContextRunner (asio::io_context &ioContext)
 Start running the supplied I/O context.
 
 ~AsioIoContextRunner ()
 Stop the worker thread.
 
 AsioIoContextRunner (const AsioIoContextRunner &)=delete
 
AsioIoContextRunner & operator= (const AsioIoContextRunner &)=delete
 
- Public Member Functions inherited from profinet::IAsioIoContextRunner
virtual ~IAsioIoContextRunner ()=default
 
 IAsioIoContextRunner ()=default
 
 IAsioIoContextRunner (const IAsioIoContextRunner &)=delete
 
IAsioIoContextRunner & operator= (const IAsioIoContextRunner &)=delete
 
 IAsioIoContextRunner (IAsioIoContextRunner &&)=delete
 
IAsioIoContextRunner & operator= (IAsioIoContextRunner &&)=delete
 

Private Attributes

asio::io_context & ioContext
 
asio::executor_work_guard< asio::io_context::executor_type > workGuard
 
std::jthread thread
 

Detailed Description

Keeps an Asio I/O context running on a dedicated worker thread.

The caller owns the io_context itself. This class only owns the work guard and worker thread required to keep the context executing.

The runner must outlive all asynchronous operations using the context.

Definition at line 34 of file AsioIoContextRunner.h.

Constructor & Destructor Documentation

◆ AsioIoContextRunner() [1/2]

profinet::AsioIoContextRunner::AsioIoContextRunner ( asio::io_context &  ioContext)
inlineexplicit

Start running the supplied I/O context.

Parameters
ioContextI/O context to execute.

Definition at line 39 of file AsioIoContextRunner.h.

References ioContext.

◆ ~AsioIoContextRunner()

profinet::AsioIoContextRunner::~AsioIoContextRunner ( )
inline

Stop the worker thread.

Definition at line 50 of file AsioIoContextRunner.h.

References ioContext, thread, and workGuard.

◆ AsioIoContextRunner() [2/2]

profinet::AsioIoContextRunner::AsioIoContextRunner ( const AsioIoContextRunner &  )
delete

Member Function Documentation

◆ operator=()

AsioIoContextRunner & profinet::AsioIoContextRunner::operator= ( const AsioIoContextRunner &  )
delete

Member Data Documentation

◆ ioContext

asio::io_context& profinet::AsioIoContextRunner::ioContext
private

Definition at line 65 of file AsioIoContextRunner.h.

Referenced by AsioIoContextRunner(), and ~AsioIoContextRunner().

◆ thread

std::jthread profinet::AsioIoContextRunner::thread
private

Definition at line 67 of file AsioIoContextRunner.h.

Referenced by ~AsioIoContextRunner().

◆ workGuard

asio::executor_work_guard<asio::io_context::executor_type> profinet::AsioIoContextRunner::workGuard
private

Definition at line 66 of file AsioIoContextRunner.h.

Referenced by ~AsioIoContextRunner().


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