sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_shutdown_signaler.hpp
Go to the documentation of this file.
1#pragma once
2/*
3# Copyright (c) 2022-2026 Murilo Marques Marinho
4#
5# This file is part of sas_core.
6#
7# sas_core is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# sas_core is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public License
18# along with sas_core. If not, see <https://www.gnu.org/licenses/>.
19#
20# ################################################################
21#
22# Author: Murilo M. Marinho, email: murilomarinho@ieee.org
23#
24# ################################################################*/
25
35#include<atomic>
36
37namespace sas
38{
40 {
41 private:
42 std::atomic_bool* external_shutdown_signal_{nullptr};
43 bool internal_shutdown_signal_{false};
44 public:
48 ShutdownSignaler() = default;
53 ShutdownSignaler(std::atomic_bool* external_shutdown_signal):
54 external_shutdown_signal_(external_shutdown_signal)
55 {
56
57 };
58
63 bool should_shutdown();
64
68 void shutdown();
69 };
70}
Definition sas_shutdown_signaler.hpp:40
ShutdownSignaler(std::atomic_bool *external_shutdown_signal)
Construct a ShutdownSignaler using an external atomic flag.
Definition sas_shutdown_signaler.hpp:53
void shutdown()
Trigger a shutdown signal.
Definition sas_shutdown_signaler.cpp:41
ShutdownSignaler()=default
Default constructor.
bool should_shutdown()
Check whether a shutdown has been requested.
Definition sas_shutdown_signaler.cpp:32