/workspaces/astro/sol3-sdk/cpp/sol3/process_manager/process_manager.h Source File

Space-ng SDK: /workspaces/astro/sol3-sdk/cpp/sol3/process_manager/process_manager.h Source File
Space-ng SDK
process_manager.h
Go to the documentation of this file.
1 // Copyright (c) Space-ng, inc. All rights reserved.
2 
3 #pragma once
4 
5 #include "sol3/asio/strand.h"
10 #include "sol3/process_manager/msg/process_manager_config.h"
13 
14 #include <boost/asio/io_context.hpp>
15 
16 #include <memory>
17 
18 namespace sol3::process_manager {
19 
26 
27 class ProcessManager : public std::enable_shared_from_this<ProcessManager> {
28  public:
36  static std::shared_ptr<ProcessManager> create(
37  asio::Strand strand,
38  core::ShmemExchange& exchange,
39  msg::ProcessManagerConfigT const& config);
40 
43  void asyncStart();
44 
47  void asyncStop();
48 
52  std::vector<msg::ProcessTelemetryT> testGetProcessTelemetry() const;
53 
54  private:
62  asio::Strand strand,
63  core::ShmemExchange& exchange,
64  msg::ProcessManagerConfigT const& config);
65 
69  void start();
70 
73  void stop();
74 
77  void handleControlMessage();
78 
80  msg::ProcessManagerConfigT config_;
81 
83  std::map<std::string, std::shared_ptr<Process>> processes_;
84 
86  core::ShmemExchange& exchange_;
87 
90 
93 
96 
98  asio::Strand strand_;
99 
101  std::shared_ptr<core::IAsyncPeriodic> control_periodic_;
102 
104  std::shared_ptr<core::IAsyncPeriodic> telemetry_periodic_;
105 };
106 
107 } // namespace sol3::process_manager
Definition: message_input.h:23
Definition: message_output.h:20
Definition: shmem_exchange.h:54
Manages the lifecycle of multiple child processes with auto-restart and control capabilities.
Definition: process_manager.h:27
void asyncStart()
Asynchronously starts all managed processes and begins control/telemetry loops.
std::vector< msg::ProcessTelemetryT > testGetProcessTelemetry() const
Retrieves telemetry for all managed processes.
void asyncStop()
Asynchronously stops all managed processes and cancels control/telemetry loops.
static std::shared_ptr< ProcessManager > create(asio::Strand strand, core::ShmemExchange &exchange, msg::ProcessManagerConfigT const &config)
Factory method to create a ProcessManager instance.
boost::asio::strand< boost::asio::io_context::executor_type > Strand
Definition: strand.h:8
Definition: process.h:20