SMACC2
Loading...
Searching...
No Matches
cp_http_connection_manager.hpp
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// HTTP Connection Manager Component - Manages io_context and thread lifecycle
16// Authors: Claude (Anthropic AI)
17
18#pragma once
19
20#include <boost/asio/any_io_executor.hpp>
21#include <boost/asio/executor_work_guard.hpp>
22#include <boost/asio/io_context.hpp>
23#include <boost/asio/strand.hpp>
24#include <memory>
25#include <smacc2/component.hpp>
26#include <thread>
27
28namespace cl_http
29{
30
31// Manages io_context and worker thread for HTTP operations
32// Provides strand for thread-safe session operations
34{
35public:
38
39 void onInitialize() override;
40
41 // Get strand for thread-safe session operations
42 boost::asio::any_io_executor getStrand();
43
44 // Access to underlying io_context
45 boost::asio::io_context & getIoContext();
46
47private:
48 boost::asio::io_context io_context_;
49 boost::asio::executor_work_guard<decltype(io_context_)::executor_type> worker_guard_;
50 std::thread io_thread_;
52};
53
54} // namespace cl_http
boost::asio::any_io_executor getStrand()
boost::asio::executor_work_guard< decltype(io_context_)::executor_type > worker_guard_