SMACC2
Loading...
Searching...
No Matches
smacc2_client_library
cl_http
src
cl_http
components
cp_http_connection_manager.cpp
Go to the documentation of this file.
1
// Copyright 2024 RobosoftAI Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
/*****************************************************************************************************************
16
*
17
* Authors: Claude (Anthropic AI)
18
*
19
******************************************************************************************************************/
20
21
#include <
cl_http/components/cp_http_connection_manager.hpp
>
22
23
namespace
cl_http
24
{
25
26
CpHttpConnectionManager::CpHttpConnectionManager
()
27
: worker_guard_(boost::asio::make_work_guard(io_context_.get_executor())), initialized_(false)
28
{
29
}
30
31
CpHttpConnectionManager::~CpHttpConnectionManager
()
32
{
33
if
(
initialized_
)
34
{
35
worker_guard_
.reset();
36
if
(
io_thread_
.joinable())
37
{
38
io_thread_
.join();
39
}
40
}
41
}
42
43
void
CpHttpConnectionManager::onInitialize
()
44
{
45
if
(!
initialized_
)
46
{
47
io_thread_
= std::thread([
this
]() {
io_context_
.run(); });
48
initialized_
=
true
;
49
}
50
}
51
52
boost::asio::any_io_executor
CpHttpConnectionManager::getStrand
()
53
{
54
return
boost::asio::make_strand(
io_context_
);
55
}
56
57
boost::asio::io_context &
CpHttpConnectionManager::getIoContext
() {
return
io_context_
; }
58
59
}
// namespace cl_http
cl_http::CpHttpConnectionManager::io_context_
boost::asio::io_context io_context_
Definition
cp_http_connection_manager.hpp:48
cl_http::CpHttpConnectionManager::onInitialize
void onInitialize() override
Definition
cp_http_connection_manager.cpp:43
cl_http::CpHttpConnectionManager::CpHttpConnectionManager
CpHttpConnectionManager()
Definition
cp_http_connection_manager.cpp:26
cl_http::CpHttpConnectionManager::initialized_
bool initialized_
Definition
cp_http_connection_manager.hpp:51
cl_http::CpHttpConnectionManager::io_thread_
std::thread io_thread_
Definition
cp_http_connection_manager.hpp:50
cl_http::CpHttpConnectionManager::getStrand
boost::asio::any_io_executor getStrand()
Definition
cp_http_connection_manager.cpp:52
cl_http::CpHttpConnectionManager::~CpHttpConnectionManager
virtual ~CpHttpConnectionManager()
Definition
cp_http_connection_manager.cpp:31
cl_http::CpHttpConnectionManager::worker_guard_
boost::asio::executor_work_guard< decltype(io_context_)::executor_type > worker_guard_
Definition
cp_http_connection_manager.hpp:49
cl_http::CpHttpConnectionManager::getIoContext
boost::asio::io_context & getIoContext()
Definition
cp_http_connection_manager.cpp:57
cp_http_connection_manager.hpp
cl_http
Definition
cl_http.hpp:45
Generated by
1.12.0