SMACC2
Loading...
Searching...
No Matches
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
22
23namespace cl_http
24{
25
27: worker_guard_(boost::asio::make_work_guard(io_context_.get_executor())), initialized_(false)
28{
29}
30
32{
33 if (initialized_)
34 {
35 worker_guard_.reset();
36 if (io_thread_.joinable())
37 {
38 io_thread_.join();
39 }
40 }
41}
42
44{
45 if (!initialized_)
46 {
47 io_thread_ = std::thread([this]() { io_context_.run(); });
48 initialized_ = true;
49 }
50}
51
52boost::asio::any_io_executor CpHttpConnectionManager::getStrand()
53{
54 return boost::asio::make_strand(io_context_);
55}
56
57boost::asio::io_context & CpHttpConnectionManager::getIoContext() { return io_context_; }
58
59} // namespace cl_http
boost::asio::any_io_executor getStrand()
boost::asio::executor_work_guard< decltype(io_context_)::executor_type > worker_guard_