Skip to content

Commit 7c78734

Browse files
Get rid of ReportExecutionState (#253)
* Get rid of ReportExecutionState nearly everywhere * Replace ReportExecutionState with report_running by hand * Don't include lifecycleclient_internal in lifecycle_client * Merge lifecycle_client(impl) into report_running(impl)
1 parent 0b3e018 commit 7c78734

38 files changed

Lines changed: 124 additions & 336 deletions

examples/control_application/control_daemon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <chrono>
1717
#include <iostream>
1818

19-
#include <score/mw/lifecycle/lifecycle_client.h>
19+
#include <score/mw/lifecycle/report_running.h>
2020
#include <score/mw/lifecycle/control_client.h>
2121
#include "ipc_dropin/socket.hpp"
2222
#include "control.hpp"
@@ -30,7 +30,7 @@ int main(int argc, char** argv) {
3030
signal(SIGINT, signalHandler);
3131
signal(SIGTERM, signalHandler);
3232

33-
score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning);
33+
score::mw::lifecycle::report_running();
3434

3535
ipc_dropin::Socket<static_cast<size_t>(sizeof(RunTargetInfo)), control_socket_capacity> sm_control_socket{};
3636
if (sm_control_socket.create(control_socket_path, 600) != ipc_dropin::ReturnCode::kOk) {

examples/cpp_supervised_app/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <sys/prctl.h>
2424
#endif
2525

26-
#include <score/mw/lifecycle/lifecycle_client.h>
26+
#include <score/mw/lifecycle/report_running.h>
2727
#include <score/mw/log/rust/stdout_logger_init.h>
2828
#include <score/mw/health/common.h>
2929
#include <score/mw/health/health_monitor.h>
@@ -146,7 +146,7 @@ int main(int argc, char** argv)
146146

147147
hm.start();
148148

149-
score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning);
149+
score::mw::lifecycle::report_running();
150150

151151
auto deadline_mon = std::move(*deadline_monitor_res);
152152

score/launch_manager/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <memory>
2020

2121
#include <vector>
22-
#include "score/mw/lifecycle/lifecycle_client.h"
2322
#include "score/mw/lifecycle/control_client.h"
2423
#include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemonConfig.hpp"
2524
#include "score/mw/launch_manager/alive_monitor/details/daemon/SwClusterHandler.hpp"

score/launch_manager/lifecycle_client/BUILD

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ cc_library(
2121
deps = [
2222
":aasapplicationcontainer",
2323
":application",
24-
":lifecycleclient_internal",
2524
":lifecyclemanager",
2625
":report_running",
2726
":runapplication",
@@ -145,26 +144,7 @@ cc_library(
145144
tags = ["FUSA"],
146145
visibility = ["//score/launch_manager:__subpackages__"],
147146
deps = [
148-
":lifecycleclient_internal",
149-
],
150-
)
151-
152-
cc_library(
153-
name = "lifecycleclient_internal",
154-
srcs = [
155-
"src/lifecycle_client.cpp",
156-
],
157-
hdrs = [
158-
"src/lifecycle_client.h",
159-
],
160-
features = COMPILER_WARNING_FEATURES,
161-
include_prefix = "score/mw/lifecycle",
162-
strip_include_prefix = "/score/launch_manager/lifecycle_client/src",
163-
tags = ["FUSA"],
164-
visibility = ["//score/launch_manager/lifecycle_client:__subpackages__"],
165-
deps = [
166-
"//score/launch_manager:error_event",
167-
"//score/launch_manager/lifecycle_client/src/details:lifecycle_client_impl",
147+
"//score/launch_manager/lifecycle_client/src/details:report_running_impl",
168148
],
169149
)
170150

score/launch_manager/lifecycle_client/src/details/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
load("@rules_cc//cc:defs.bzl", "cc_library")
1414

1515
cc_library(
16-
name = "lifecycle_client_impl",
17-
srcs = ["lifecycle_client_impl.cpp"],
18-
hdrs = ["lifecycle_client_impl.hpp"],
16+
name = "report_running_impl",
17+
srcs = ["report_running_impl.cpp"],
18+
hdrs = ["report_running_impl.hpp"],
1919
include_prefix = "score/mw/lifecycle/lifecycle_client/details",
2020
strip_include_prefix = "/score/launch_manager/lifecycle_client/src/details",
2121
visibility = ["//score/launch_manager/lifecycle_client:__pkg__"],

score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.cpp renamed to score/launch_manager/lifecycle_client/src/details/report_running_impl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
#include "score/mw/launch_manager/osal/ipc_comms.hpp"
2424
#include "score/mw/launch_manager/common/constants.hpp"
2525
#include "score/mw/lifecycle/execution_error.h"
26-
#include "score/mw/lifecycle/lifecycle_client/details/lifecycle_client_impl.hpp"
26+
#include "score/mw/lifecycle/lifecycle_client/details/report_running_impl.hpp"
2727

2828
using namespace score::lcm::internal::osal;
2929

3030
namespace score::mw::lifecycle {
31-
std::atomic_bool LifecycleClientImpl::reported{false};
31+
std::atomic_bool ReportRunningImpl::reported{false};
3232

33-
LifecycleClientImpl::LifecycleClientImpl() noexcept = default;
33+
ReportRunningImpl::ReportRunningImpl() noexcept = default;
3434

35-
LifecycleClientImpl::~LifecycleClientImpl() noexcept = default;
35+
ReportRunningImpl::~ReportRunningImpl() noexcept = default;
3636

37-
score::Result<std::monostate> LifecycleClientImpl::ReportRunningState() const noexcept
37+
score::Result<std::monostate> ReportRunningImpl::ReportRunningState() const noexcept
3838
{
3939
score::Result<std::monostate> retVal{score::MakeUnexpected(ExecErrc::kCommunicationError)};
4040

@@ -51,7 +51,7 @@ namespace score::mw::lifecycle {
5151
return retVal;
5252
}
5353

54-
score::Result<std::monostate> LifecycleClientImpl::reportKRunningtoDaemon() const noexcept
54+
score::Result<std::monostate> ReportRunningImpl::reportKRunningtoDaemon() const noexcept
5555
{
5656
score::Result<std::monostate> comms_error {score::MakeUnexpected(ExecErrc::kCommunicationError)};
5757

@@ -103,7 +103,7 @@ namespace score::mw::lifecycle {
103103

104104
return comms_error;
105105
}
106-
106+
107107
// Final post to semaphore, so LM know that communication channel can be closed now
108108
sync->send_sync_.post();
109109
// Mark as reported if successful

score/launch_manager/lifecycle_client/src/details/lifecycle_client_impl.hpp renamed to score/launch_manager/lifecycle_client/src/details/report_running_impl.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
********************************************************************************/
1313

1414

15-
#ifndef _INCLUDED_LIFECYCLECLIENTIMPL_
16-
#define _INCLUDED_LIFECYCLECLIENTIMPL_
15+
#ifndef _INCLUDED_REPORTRUNNINGIMPL_
16+
#define _INCLUDED_REPORTRUNNINGIMPL_
1717

1818
#include <atomic>
1919

@@ -22,22 +22,21 @@
2222

2323
namespace score::mw::lifecycle {
2424

25-
/// @brief Class implementing Pimpl (pointer to implementation) design pattern for LifecycleClient (an AUTOSAR data type).
26-
/// The lifecycle_client_lib strive to provide ABI compatibility as much as we can, so for this reason Pimpl pattern is deployed.
27-
/// Design of this class fulfil the needs of the pattern mentioned.
28-
/// More info can be found here: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ri-pimpl
29-
class LifecycleClientImpl final {
25+
/// @brief Implementation class for report_running(), handling the actual IPC
26+
/// communication with the Launch Manager to signal that this process has
27+
/// entered its Running state.
28+
class ReportRunningImpl final {
3029
public:
31-
/// @brief Constructor that creates LifecycleClientImpl (implementation of Lifecycle Client)
32-
LifecycleClientImpl() noexcept;
30+
/// @brief Constructor
31+
ReportRunningImpl() noexcept;
3332

34-
/// @brief Destructor of the LifecycleClientImpl (implementation of Lifecycle Client)
35-
~LifecycleClientImpl() noexcept;
33+
/// @brief Destructor
34+
~ReportRunningImpl() noexcept;
3635

3736
// This class is trivially copyable / movable
3837
// For this reason we are applying the rule of zero
3938

40-
/// @brief Implementation of a interface for a Process to report its running state to Launch Manager.
39+
/// @brief Reports the Running state to the Launch Manager.
4140
///
4241
/// @returns An instance of score::Result. The instance holds an ErrorCode containing either one of the specified errors or a void-value.
4342
/// @error score::mw::lifecycle::ExecErrc::kCommunicationError Communication error between Application and Launch Manager, e.g. unable to report state for Non-reporting Process.
@@ -46,10 +45,10 @@ class LifecycleClientImpl final {
4645

4746
private:
4847
/// @brief Variable to remember if kRunning was already reported for the process using lifecycle_client_lib.
49-
/// Please note that LifecycleClient::ReportRunningState() method, the original method, is declared as a const method.
48+
/// Please note that ReportRunningState() method is declared as a const method.
5049
/// Thanks to this, user can choose to declare instance of this class as a constant variable and reporting kRunning will still work.
5150
/// However, this prevent us from implementing certain optimizations, after initial kRunning was reported.
52-
/// To mitigate this, we can store this information outside of LifecycleClientImpl class or have a mutable variable.
51+
/// To mitigate this, we can store this information outside of ReportRunningImpl class or have a mutable variable.
5352
/// After short discussion, mutable variable was chosen.
5453
/// True if kRunning was already reported by the process using this library.
5554
/// False if kRunning was not yet reported by the process using this library.
@@ -62,4 +61,4 @@ class LifecycleClientImpl final {
6261

6362
} // namespace score::mw::lifecycle
6463

65-
#endif // _INCLUDED_LIFECYCLECLIENTIMPL_
64+
#endif // _INCLUDED_REPORTRUNNINGIMPL_

score/launch_manager/lifecycle_client/src/lifecycle_client.cpp

Lines changed: 0 additions & 83 deletions
This file was deleted.

score/launch_manager/lifecycle_client/src/lifecycle_client.h

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)