Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/control_application/control_daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <chrono>
#include <iostream>

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

score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning);
score::mw::lifecycle::report_running();

ipc_dropin::Socket<static_cast<size_t>(sizeof(RunTargetInfo)), control_socket_capacity> sm_control_socket{};
if (sm_control_socket.create(control_socket_path, 600) != ipc_dropin::ReturnCode::kOk) {
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp_supervised_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <sys/prctl.h>
#endif

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

hm.start();

score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(score::mw::lifecycle::ExecutionState::kRunning);
score::mw::lifecycle::report_running();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <memory>

#include <vector>
#include "score/mw/lifecycle/lifecycle_client.h"
#include "score/mw/lifecycle/control_client.h"
#include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemonConfig.hpp"
#include "score/mw/launch_manager/alive_monitor/details/daemon/SwClusterHandler.hpp"
Expand Down
22 changes: 1 addition & 21 deletions score/launch_manager/lifecycle_client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ cc_library(
deps = [
":aasapplicationcontainer",
":application",
":lifecycleclient_internal",
":lifecyclemanager",
":report_running",
":runapplication",
Expand Down Expand Up @@ -145,26 +144,7 @@ cc_library(
tags = ["FUSA"],
visibility = ["//score/launch_manager:__subpackages__"],
deps = [
":lifecycleclient_internal",
],
)

cc_library(
name = "lifecycleclient_internal",
srcs = [
"src/lifecycle_client.cpp",
],
hdrs = [
"src/lifecycle_client.h",
],
features = COMPILER_WARNING_FEATURES,
include_prefix = "score/mw/lifecycle",
strip_include_prefix = "/score/launch_manager/lifecycle_client/src",
tags = ["FUSA"],
visibility = ["//score/launch_manager/lifecycle_client:__subpackages__"],
deps = [
"//score/launch_manager:error_event",
"//score/launch_manager/lifecycle_client/src/details:lifecycle_client_impl",
"//score/launch_manager/lifecycle_client/src/details:report_running_impl",
],
)

Expand Down
6 changes: 3 additions & 3 deletions score/launch_manager/lifecycle_client/src/details/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "lifecycle_client_impl",
srcs = ["lifecycle_client_impl.cpp"],
hdrs = ["lifecycle_client_impl.hpp"],
name = "report_running_impl",
srcs = ["report_running_impl.cpp"],
hdrs = ["report_running_impl.hpp"],
include_prefix = "score/mw/lifecycle/lifecycle_client/details",
strip_include_prefix = "/score/launch_manager/lifecycle_client/src/details",
visibility = ["//score/launch_manager/lifecycle_client:__pkg__"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
#include "score/mw/launch_manager/osal/ipc_comms.hpp"
#include "score/mw/launch_manager/common/constants.hpp"
#include "score/mw/lifecycle/execution_error.h"
#include "score/mw/lifecycle/lifecycle_client/details/lifecycle_client_impl.hpp"
#include "score/mw/lifecycle/lifecycle_client/details/report_running_impl.hpp"

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

namespace score::mw::lifecycle {
std::atomic_bool LifecycleClientImpl::reported{false};
std::atomic_bool ReportRunningImpl::reported{false};

LifecycleClientImpl::LifecycleClientImpl() noexcept = default;
ReportRunningImpl::ReportRunningImpl() noexcept = default;

LifecycleClientImpl::~LifecycleClientImpl() noexcept = default;
ReportRunningImpl::~ReportRunningImpl() noexcept = default;

score::Result<std::monostate> LifecycleClientImpl::ReportRunningState() const noexcept
score::Result<std::monostate> ReportRunningImpl::ReportRunningState() const noexcept
{
score::Result<std::monostate> retVal{score::MakeUnexpected(ExecErrc::kCommunicationError)};

Expand All @@ -51,7 +51,7 @@ namespace score::mw::lifecycle {
return retVal;
}

score::Result<std::monostate> LifecycleClientImpl::reportKRunningtoDaemon() const noexcept
score::Result<std::monostate> ReportRunningImpl::reportKRunningtoDaemon() const noexcept
{
score::Result<std::monostate> comms_error {score::MakeUnexpected(ExecErrc::kCommunicationError)};

Expand Down Expand Up @@ -103,7 +103,7 @@ namespace score::mw::lifecycle {

return comms_error;
}

// Final post to semaphore, so LM know that communication channel can be closed now
sync->send_sync_.post();
// Mark as reported if successful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
********************************************************************************/


#ifndef _INCLUDED_LIFECYCLECLIENTIMPL_
#define _INCLUDED_LIFECYCLECLIENTIMPL_
#ifndef _INCLUDED_REPORTRUNNINGIMPL_
#define _INCLUDED_REPORTRUNNINGIMPL_

#include <atomic>

Expand All @@ -22,22 +22,21 @@

namespace score::mw::lifecycle {

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

/// @brief Destructor of the LifecycleClientImpl (implementation of Lifecycle Client)
~LifecycleClientImpl() noexcept;
/// @brief Destructor
~ReportRunningImpl() noexcept;

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

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

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

} // namespace score::mw::lifecycle

#endif // _INCLUDED_LIFECYCLECLIENTIMPL_
#endif // _INCLUDED_REPORTRUNNINGIMPL_
83 changes: 0 additions & 83 deletions score/launch_manager/lifecycle_client/src/lifecycle_client.cpp

This file was deleted.

98 changes: 0 additions & 98 deletions score/launch_manager/lifecycle_client/src/lifecycle_client.h

This file was deleted.

Loading
Loading