SMACC2
Loading...
Searching...
No Matches
cl_http::CpHttpConnectionManager Class Reference

#include <cp_http_connection_manager.hpp>

Inheritance diagram for cl_http::CpHttpConnectionManager:
Inheritance graph
Collaboration diagram for cl_http::CpHttpConnectionManager:
Collaboration graph

Public Member Functions

 CpHttpConnectionManager ()
 
virtual ~CpHttpConnectionManager ()
 
void onInitialize () override
 
boost::asio::any_io_executor getStrand ()
 
boost::asio::io_context & getIoContext ()
 
- Public Member Functions inherited from smacc2::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 

Private Attributes

boost::asio::io_context io_context_
 
boost::asio::executor_work_guard< decltype(io_context_)::executor_type > worker_guard_
 
std::thread io_thread_
 
bool initialized_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccComponent
template<typename TOrthogonal , typename TClient >
void onComponentInitialization ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
template<typename TComponent >
void requiresComponent (TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TComponent >
void requiresComponent (std::string name, TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TClient >
void requiresClient (TClient *&requiredClientStorage)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger () const
 
ISmaccStateMachinegetStateMachine ()
 
- Protected Attributes inherited from smacc2::ISmaccComponent
ISmaccStateMachinestateMachine_
 
ISmaccClientowner_
 

Detailed Description

Definition at line 33 of file cp_http_connection_manager.hpp.

Constructor & Destructor Documentation

◆ CpHttpConnectionManager()

cl_http::CpHttpConnectionManager::CpHttpConnectionManager ( )

Definition at line 26 of file cp_http_connection_manager.cpp.

27: worker_guard_(boost::asio::make_work_guard(io_context_.get_executor())), initialized_(false)
28{
29}
boost::asio::executor_work_guard< decltype(io_context_)::executor_type > worker_guard_

◆ ~CpHttpConnectionManager()

cl_http::CpHttpConnectionManager::~CpHttpConnectionManager ( )
virtual

Definition at line 31 of file cp_http_connection_manager.cpp.

32{
33 if (initialized_)
34 {
35 worker_guard_.reset();
36 if (io_thread_.joinable())
37 {
38 io_thread_.join();
39 }
40 }
41}

References initialized_, io_thread_, and worker_guard_.

Member Function Documentation

◆ getIoContext()

boost::asio::io_context & cl_http::CpHttpConnectionManager::getIoContext ( )

Definition at line 57 of file cp_http_connection_manager.cpp.

57{ return io_context_; }

References io_context_.

◆ getStrand()

boost::asio::any_io_executor cl_http::CpHttpConnectionManager::getStrand ( )

Definition at line 52 of file cp_http_connection_manager.cpp.

53{
54 return boost::asio::make_strand(io_context_);
55}

References io_context_.

Referenced by cl_http::CpHttpRequestExecutor::executeRequest().

Here is the caller graph for this function:

◆ onInitialize()

void cl_http::CpHttpConnectionManager::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 43 of file cp_http_connection_manager.cpp.

44{
45 if (!initialized_)
46 {
47 io_thread_ = std::thread([this]() { io_context_.run(); });
48 initialized_ = true;
49 }
50}

References initialized_, io_context_, and io_thread_.

Member Data Documentation

◆ initialized_

bool cl_http::CpHttpConnectionManager::initialized_
private

Definition at line 51 of file cp_http_connection_manager.hpp.

Referenced by onInitialize(), and ~CpHttpConnectionManager().

◆ io_context_

boost::asio::io_context cl_http::CpHttpConnectionManager::io_context_
private

Definition at line 48 of file cp_http_connection_manager.hpp.

Referenced by getIoContext(), getStrand(), and onInitialize().

◆ io_thread_

std::thread cl_http::CpHttpConnectionManager::io_thread_
private

Definition at line 50 of file cp_http_connection_manager.hpp.

Referenced by onInitialize(), and ~CpHttpConnectionManager().

◆ worker_guard_

boost::asio::executor_work_guard<decltype(io_context_)::executor_type> cl_http::CpHttpConnectionManager::worker_guard_
private

Definition at line 49 of file cp_http_connection_manager.hpp.

Referenced by ~CpHttpConnectionManager().


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