diff --git a/examples/count/main.cc b/examples/count/main.cc index ca20df5d..6c1a52dc 100644 --- a/examples/count/main.cc +++ b/examples/count/main.cc @@ -5,15 +5,15 @@ using namespace reactor; using namespace std::chrono_literals; -class Count : public Reactor { +class Count final: public Reactor { private: // actions Timer timer{"timer", this}; LogicalAction counter{"counter", this}; // reactions_ - Reaction r_init{"r_init", 1, false, this, [this]() { this->init(); }}; - Reaction r_counter{"r_counter", 2, false, this, [this]() { this->print_count(); }}; + Reaction r_init{"r_init", 1, this, [this]() { this->init(); }}; + Reaction r_counter{"r_counter", 2, this, [this]() { this->print_count(); }}; public: explicit Count(Environment* env) diff --git a/examples/hello/main.cc b/examples/hello/main.cc index 3b02fd89..16884f45 100644 --- a/examples/hello/main.cc +++ b/examples/hello/main.cc @@ -6,7 +6,7 @@ using namespace reactor; using namespace std::chrono_literals; -class Hello : public Reactor { +class Hello final: public Reactor { private: // actions Timer timer{"timer", this, 1s, 2s}; diff --git a/examples/multiport_mutation/consumer.hh b/examples/multiport_mutation/consumer.hh index b2ac7324..e984517a 100644 --- a/examples/multiport_mutation/consumer.hh +++ b/examples/multiport_mutation/consumer.hh @@ -11,36 +11,35 @@ using namespace reactor; using namespace std::chrono_literals; class Consumer : public Reactor { -private: - class Inner: public Scope { - Inner(Reactor* reactor, std::size_t index) : Scope(reactor), index_(index) {} - std::size_t index_; + class Inner : public Scope { + Inner(Reactor* reactor, std::size_t index) + : Scope(reactor) + , index_(index) {} + std::size_t index_ = 0; - [[maybe_unused]] const Inner& __lf_inner = *this; + const Inner& _lf_inner = *this; - void reaction_1([[maybe_unused]] const Input& in) { - std::cout << "consumer: " << index_ << " received value:" << *in.get() << std::endl; + void reaction_1(const Input& in) const { + std::cout << "consumer: " << index_ << " received value:" << *in.get() << '\n'; } friend Consumer; }; - Inner __lf_inner; - Reaction handle{"handle", 1, this, [this]() { __lf_inner.reaction_1(this->in); }}; + Inner _lf_inner; + Reaction handle{"handle", 1, this, [this]() { _lf_inner.reaction_1(this->in); }}; + public: - Consumer(const std::string& name, Environment* env, std::size_t index) : Reactor(name, env), __lf_inner(this, index) { - std::cout << "creating instance of consumer" << std::endl; + Consumer(const std::string& name, Environment* env, std::size_t index) + : Reactor(name, env) + , _lf_inner(this, index) { + std::cout << "creating instance of consumer" << '\n'; } - ~Consumer() override { - std::cout << "Consumer Object is deleted" << std::endl; - }; + ~Consumer() override { std::cout << "Consumer Object is deleted" << '\n'; }; Input in{"in", this}; - void assemble() override { - handle.declare_trigger(&in); - } + void assemble() override { handle.declare_trigger(&in); } }; - -#endif //CONSUMER_HH +#endif // CONSUMER_HH diff --git a/examples/multiport_mutation/load_balancer.hh b/examples/multiport_mutation/load_balancer.hh index 8e744279..d13a01c0 100644 --- a/examples/multiport_mutation/load_balancer.hh +++ b/examples/multiport_mutation/load_balancer.hh @@ -15,12 +15,14 @@ using namespace std::chrono_literals; class LoadBalancer : public Reactor { private: - class Inner: public MutableScope { - Inner(Reactor* reactor) : MutableScope(reactor) {} - [[maybe_unused]] const Inner& __lf_inner = *this; + class Inner : public MutableScope { + Inner(Reactor* reactor) + : MutableScope(reactor) {} + const Inner& __lf_inner = *this; // reaction bodies - void reaction_1(const Input& inbound, LogicalAction& scale_action, Multiport>& outbound) { + void reaction_1(const Input& inbound, LogicalAction& scale_action, + Multiport>& outbound) { if (rand() % 30 == 0) { scale_action.schedule(rand() % 20 + 1); } @@ -29,13 +31,15 @@ private: outbound[sel].set(inbound.get()); } - void reaction_2(ModifableMultiport>&outbound, [[maybe_unused]] const LogicalAction& scale, Output& scale_bank) { + void reaction_2(ModifableMultiport>& outbound, + [[maybe_unused]] const LogicalAction& scale, Output& scale_bank) { ModifableMultiport>* temp = &outbound; std::size_t new_size = *scale.get(); auto antideps = (outbound[0]).anti_dependencies(); - auto change_size = std::make_shared>(temp, this->reactor_, antideps, new_size); + auto change_size = + std::make_shared>(temp, this->reactor_, antideps, new_size); add_to_transaction(change_size); @@ -48,16 +52,19 @@ private: }; Inner __lf_inner; - Reaction process{"process", 2, this, [this]() { __lf_inner.reaction_1(this->inbound, this->scale_action, this->out); }}; - Reaction scale{"scale", 1, this, [this]() { __lf_inner.reaction_2(this->out, this->scale_action, this->scale_bank); }}; + Reaction process{"process", 2, this, + [this]() { __lf_inner.reaction_1(this->inbound, this->scale_action, this->out); }}; + Reaction scale{"scale", 1, this, + [this]() { __lf_inner.reaction_2(this->out, this->scale_action, this->scale_bank); }}; public: LoadBalancer(const std::string& name, Environment* env) - : Reactor(name, env), __lf_inner(this) { + : Reactor(name, env) + , __lf_inner(this) { std::cout << "creating instance of load balancer" << std::endl; out.reserve(4); for (size_t _lf_idx = 0; _lf_idx < 4; _lf_idx++) { - std::string _lf_port_name = out.name() + "_" + std::to_string(_lf_idx); + std::string _lf_port_name = out.name() + "_" + std::to_string(_lf_idx); out.emplace_back(_lf_port_name, this); } } @@ -78,6 +85,4 @@ public: } }; - - -#endif //LOAD_BALANCER_HH +#endif // LOAD_BALANCER_HH diff --git a/examples/multiport_mutation/main.cc b/examples/multiport_mutation/main.cc index 3956b8e6..46e03d51 100644 --- a/examples/multiport_mutation/main.cc +++ b/examples/multiport_mutation/main.cc @@ -3,58 +3,55 @@ #include #include +#include "../../lib/mutation/bank.cc" +#include "../../lib/mutation/connection.cc" #include "./consumer.hh" #include "./load_balancer.hh" #include "./producer.hh" -#include "../../lib/mutation/bank.cc" -#include "../../lib/mutation/connection.cc" #include -class Deployment : public Reactor { +class Deployment final: public Reactor { std::unique_ptr producer_; std::unique_ptr load_balancer_; std::vector> consumers_; - Reaction scale_bank{"scale_bank", 1, this, [this](){this->__inner.reaction_1(this->scale, this->consumers_, load_balancer_->out);}}; + Reaction scale_bank{"scale_bank", 1, this, + [this]() { this->__inner.reaction_1(this->scale, this->consumers_, load_balancer_->out); }}; public: - -class Inner: public MutableScope { + class Inner : public MutableScope { int state = 0; - [[maybe_unused]] const Inner& __lf_inner = *this; -public: + const Inner& _lf_inner = *this; - Inner(Reactor* reactor) : MutableScope(reactor) {} - void reaction_1(const Input& scale, std::vector>& reactor_bank, ModifableMultiport>& load_balancer) { + public: + Inner(Reactor* reactor) + : MutableScope(reactor) {} + void reaction_1(const Input& scale, std::vector>& reactor_bank, + ModifableMultiport>& load_balancer) { std::size_t new_size = *scale.get(); std::size_t old_size = reactor_bank.size(); - std::function(Reactor*, std::size_t)> lambda = [](Reactor* reactor, std::size_t index) { - std::string __lf_inst_name = "consumer_" + std::to_string(index); - return std::make_unique(__lf_inst_name, reactor->environment(), index); + std::function lambda = [](Reactor* reactor, std::size_t index) { + std::string _lf_inst_name = "consumer_" + std::to_string(index); + return std::make_unique(_lf_inst_name, reactor->environment(), index); }; - auto change_size = std::make_shared>>(&reactor_bank, this->reactor_, new_size, lambda); + + auto change_size = std::make_shared>>( + &reactor_bank, this->reactor_, new_size, lambda); add_to_transaction(change_size); - // old topology commit_transaction(); - // new topology - - if (old_size > new_size) { - for (auto i = 0; i < old_size - new_size; i++) { - } - } else { - std::cout << "load_balancer size:" << load_balancer.size() << " bank size: " << reactor_bank.size() << std::endl; + if (old_size < new_size) { for (auto i = 0; i < new_size; i++) { - auto add_conn = std::make_shared, Input>>(&load_balancer[i], &reactor_bank[i].get()->in, reactor_); - add_to_transaction(add_conn); + auto add_conn = std::make_shared, Input>>( + &load_balancer[i], &reactor_bank[i].get()->in, reactor_); + add_to_transaction(add_conn); } - commit_transaction(true); } - std::cout << "new bank size:" << reactor_bank.size() << std::endl; + commit_transaction(true); } friend LoadBalancer; @@ -62,14 +59,16 @@ class Inner: public MutableScope { Inner __inner; - Deployment(const std::string& name, Environment* env) : Reactor(name, env), __inner(this), - producer_(std::make_unique("producer", environment())), - load_balancer_(std::make_unique("load_balancer", environment())) { - std::cout << "creating instance of deployment" << std::endl; + Deployment(const std::string& name, Environment* env) + : Reactor(name, env) + , __inner(this) + , producer_(std::make_unique("producer", environment())) + , load_balancer_(std::make_unique("load_balancer", environment())) { + std::cout << "creating instance of deployment" << '\n'; consumers_.reserve(4); - for (size_t __lf_idx = 0; __lf_idx < 4; __lf_idx++) { - std::string __lf_inst_name = "consumer_" + std::to_string(__lf_idx); - consumers_.push_back(std::make_unique(__lf_inst_name, environment(), __lf_idx)); + for (size_t _lf_idx = 0; _lf_idx < 4; _lf_idx++) { + std::string _lf_inst_name = "consumer_" + std::to_string(_lf_idx); + consumers_.push_back(std::make_unique(_lf_inst_name, environment(), _lf_idx)); } } ~Deployment() override = default; @@ -77,8 +76,8 @@ class Inner: public MutableScope { Input scale{"scale", this}; void assemble() override { - for (size_t __lf_idx = 0; __lf_idx < 4; __lf_idx++) { - environment()->draw_connection(load_balancer_->out[__lf_idx], consumers_[__lf_idx]->in, ConnectionProperties{}); + for (size_t _lf_idx = 0; _lf_idx < 4; _lf_idx++) { + environment()->draw_connection(load_balancer_->out[_lf_idx], consumers_[_lf_idx]->in, ConnectionProperties{}); environment()->draw_connection(producer_->value, load_balancer_->inbound, ConnectionProperties{}); } environment()->draw_connection(load_balancer_->scale_bank, scale, ConnectionProperties{}); @@ -86,9 +85,7 @@ class Inner: public MutableScope { } }; - auto main() -> int { - //srand(time(nullptr)); Environment env{4, true}; auto deployment = std::make_unique("c1", &env); env.optimize(); diff --git a/examples/multiport_mutation/producer.hh b/examples/multiport_mutation/producer.hh index 7a998cbb..9b445e8b 100644 --- a/examples/multiport_mutation/producer.hh +++ b/examples/multiport_mutation/producer.hh @@ -13,23 +13,29 @@ using namespace std::chrono_literals; class Producer : public Reactor { private: Timer timer{"timer", this, 1s, 1s}; - Reaction r_timer{"r_timer", 1, this, [this]() { __lf_inner.reaction_1(this->value);}}; + Reaction r_timer{"r_timer", 1, this, [this]() { __lf_inner.reaction_1(this->value); }}; + + class Inner : public Scope { + unsigned int counter_ = 0; + const Inner& __lf_inner = *this; - class Inner: public Scope { - unsigned itr = 0; - [[maybe_unused]] const Inner& __lf_inner = *this; void reaction_1([[maybe_unused]] Output& out) { - std::cout << "producing value:" << itr << std::endl; - out.set(itr++); + std::cout << "producing value:" << counter_ << std::endl; + out.set(counter_++); } - explicit Inner(Reactor* reactor) : Scope(reactor) {} + + explicit Inner(Reactor* reactor) + : Scope(reactor) {} friend Producer; }; Inner __lf_inner; + public: - Producer(const std::string& name, Environment* env) : Reactor(name, env), __lf_inner(this) { + Producer(const std::string& name, Environment* env) + : Reactor(name, env) + , __lf_inner(this) { std::cout << "creating instance of producer" << std::endl; } Producer() = delete; @@ -43,4 +49,4 @@ public: } }; -#endif //PRODUCER_HH +#endif // PRODUCER_HH diff --git a/examples/ports/main.cc b/examples/ports/main.cc index d1dda5d1..7463c6da 100644 --- a/examples/ports/main.cc +++ b/examples/ports/main.cc @@ -5,7 +5,7 @@ using namespace reactor; using namespace std::chrono_literals; -class Trigger : public Reactor { +class Trigger final: public Reactor { private: Timer timer; Reaction r_timer{"r_timer", 1, this, [this]() { on_timer(); }}; @@ -25,7 +25,7 @@ class Trigger : public Reactor { void on_timer() { trigger.set(); } }; -class Counter : public Reactor { +class Counter final: public Reactor { private: int value_{0}; Reaction r_trigger{"r_trigger", 1, this, [this]() { on_trigger(); }}; @@ -49,7 +49,7 @@ class Counter : public Reactor { } }; -class Printer : public Reactor { +class Printer final: public Reactor { private: Reaction r_value{"r_value", 1, this, [this]() { this->on_value(); }}; @@ -67,7 +67,7 @@ class Printer : public Reactor { void on_value() { std::cout << this->name() << ": " << *value.get() << '\n'; } }; -class Adder : public Reactor { +class Adder final: public Reactor { private: Reaction r_add{"r_add", 1, this, [this]() { this->add(); }}; diff --git a/examples/power_train/main.cc b/examples/power_train/main.cc index 155c3501..71adbd26 100644 --- a/examples/power_train/main.cc +++ b/examples/power_train/main.cc @@ -4,7 +4,7 @@ using namespace reactor; -class LeftPedal : public Reactor { +class LeftPedal final: public Reactor { public: // ports Output angle{"angle", this}; // NOLINT @@ -30,7 +30,7 @@ class LeftPedal : public Reactor { } }; -class RightPedal : public Reactor { +class RightPedal final: public Reactor { public: // ports Output angle{"angle", this}; // NOLINT @@ -60,7 +60,7 @@ class RightPedal : public Reactor { } }; -class BrakeControl : public Reactor { +class BrakeControl final: public Reactor { public: // ports Input angle{"angle", this}; // NOLINT @@ -81,7 +81,7 @@ class BrakeControl : public Reactor { } }; -class EngineControl : public Reactor { +class EngineControl final: public Reactor { public: // ports Input angle{"angle", this}; // NOLINT @@ -118,7 +118,7 @@ class EngineControl : public Reactor { } }; -class Brake : public Reactor { +class Brake final: public Reactor { public: // ports Input force{"force", this}; // NOLINT @@ -136,11 +136,11 @@ class Brake : public Reactor { void assemble() override { r1.declare_trigger(&force); } }; -class Engine : public Reactor { +class Engine final: public Reactor { public: // ports Input torque{"torque", this}; // NOLINT - Multiport control_input; + private: // reactions_ Reaction r1{"1", 1, this, [this]() { reaction_1(); }}; @@ -180,12 +180,3 @@ auto main() -> int { return 0; } - -class ReactionScope : public MutableScope { - void reaction_0() { - MutationChangeMultiportSize change_multiport_width{&this->self_->control_input, 6}; - this->add_to_transaction(&change_multiport_width); - - this->commit_transaction(); - } -}; diff --git a/examples/unit_tests_mutations/main.cc b/examples/unit_tests_mutations/main.cc index 0066d705..d7de41e7 100644 --- a/examples/unit_tests_mutations/main.cc +++ b/examples/unit_tests_mutations/main.cc @@ -6,37 +6,42 @@ using namespace std::chrono_literals; -class TestMultiport: public reactor::Reactor { +class TestMultiport final: public reactor::Reactor { reactor::ModifableMultiport> test_multiport_{"modifable_multiports_"}; reactor::Timer timer_{"timer", this, 1s}; reactor::LogicalAction scale{"scale", this}; - reactor::Reaction trigger_reaction_{"trigger_reaction", 1, this, [this](){this->__inner.reaction_1(scale);}}; - reactor::Reaction test_reaction_{"test_reaction", 2, this, [this](){this->__inner.reaction_2(test_multiport_, scale);}}; - reactor::Reaction validate_reaction_{"validate_reaction", 3, this, [this](){this->__inner.reaction_3(test_multiport_);}}; -public: + reactor::Reaction trigger_reaction_{"trigger_reaction", 1, this, [this]() { this->__inner.reaction_1(scale); }}; + reactor::Reaction test_reaction_{"test_reaction", 2, this, + [this]() { this->__inner.reaction_2(test_multiport_, scale); }}; + reactor::Reaction validate_reaction_{"validate_reaction", 3, this, + [this]() { this->__inner.reaction_3(test_multiport_); }}; -class Inner: public reactor::MutableScope { +public: + class Inner : public reactor::MutableScope { int state = 0; std::vector sizes = {4, 5, 6, 5, 4, 3}; [[maybe_unused]] const Inner& __lf_inner = *this; -public: - Inner(Reactor* reactor) : MutableScope(reactor) {} + public: + Inner(Reactor* reactor) + : MutableScope(reactor) {} void reaction_1(reactor::LogicalAction& scale) { - int size = sizes[state]; + const int size = sizes[state]; state = (state + 1) % sizes.size(); std::cout << "set: " << size << std::endl; scale.schedule(size); } - void reaction_2(reactor::ModifableMultiport>& test_multiport, reactor::LogicalAction& scale) { + void reaction_2(reactor::ModifableMultiport>& test_multiport, + reactor::LogicalAction& scale) { reactor::ModifableMultiport>* temp = &test_multiport; std::size_t new_size = *scale.get(); auto anti_dep = test_multiport[0].anti_dependencies(); - reactor::MutationChangeOutputMultiportSize change_size{temp, this->reactor_, anti_dep, new_size}; - add_to_transaction(&change_size); + const auto change_size = + std::make_shared>(temp, this->reactor_, anti_dep, new_size); + add_to_transaction(change_size); commit_transaction(); } @@ -50,12 +55,14 @@ class Inner: public reactor::MutableScope { Inner __inner; - TestMultiport(const std::string& name, reactor::Environment* env) : Reactor(name, env), __inner(this) { + TestMultiport(const std::string& name, reactor::Environment* env) + : Reactor(name, env) + , __inner(this) { std::cout << "creating instance of deployment" << std::endl; test_multiport_.reserve(4); for (size_t _lf_idx = 0; _lf_idx < 4; _lf_idx++) { - std::string _lf_port_name = test_multiport_.name() + "_" + std::to_string(_lf_idx); + std::string _lf_port_name = test_multiport_.name() + "_" + std::to_string(_lf_idx); test_multiport_.emplace_back(_lf_port_name, this); } } @@ -65,11 +72,9 @@ class Inner: public reactor::MutableScope { trigger_reaction_.declare_trigger(&timer_); trigger_reaction_.declare_schedulable_action(&scale); test_reaction_.declare_trigger(&scale); - } }; - auto main() -> int { // srand(time(nullptr)); reactor::Environment env{4}; diff --git a/include/reactor-cpp/environment.hh b/include/reactor-cpp/environment.hh index fdfb30b7..6051b5f4 100644 --- a/include/reactor-cpp/environment.hh +++ b/include/reactor-cpp/environment.hh @@ -112,7 +112,7 @@ public: void remove_top_level_reactor(Reactor* reactor) { auto elements_erased = top_level_reactors_.erase(reactor); if (elements_erased == 0) { - std::cout << "no elements erased" << std::endl; + std::cout << "no elements erased" << '\n'; } } diff --git a/include/reactor-cpp/graph.hh b/include/reactor-cpp/graph.hh index 08af8d65..bd4dfb87 100644 --- a/include/reactor-cpp/graph.hh +++ b/include/reactor-cpp/graph.hh @@ -9,6 +9,7 @@ #ifndef REACTOR_CPP_GRAPH_HH #define REACTOR_CPP_GRAPH_HH +#include #include #include #include @@ -67,13 +68,12 @@ public: auto remove_edge(E source, E destinations) noexcept -> std::optional

{ if (graph_.find(source) == std::end(graph_)) { return std::nullopt; - } else { - auto conns = std::find_if(std::begin(graph_[source]), std::end(graph_[source]), - [destinations](auto val) { return val.second == destinations; }); + } + auto conns = std::find_if(std::begin(graph_[source]), std::end(graph_[source]), + [destinations](auto val) { return val.second == destinations; }); - if (conns != std::end(graph_[source])) { - graph_[source].erase(conns); - } + if (conns != std::end(graph_[source])) { + graph_[source].erase(conns); } } diff --git a/include/reactor-cpp/multiport.hh b/include/reactor-cpp/multiport.hh index d0aa4888..7e032b0c 100644 --- a/include/reactor-cpp/multiport.hh +++ b/include/reactor-cpp/multiport.hh @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "assert.hh" @@ -49,10 +50,10 @@ protected: void register_port(BasePort& port, size_t idx); public: - explicit BaseMultiport(const std::string& name) - : multiport_name_(name){}; + explicit BaseMultiport(std::string name) + : multiport_name_(std::move(name)){}; ~BaseMultiport() = default; - auto name() const -> std::string { return multiport_name_; } + [[nodiscard]] auto name() const -> std::string { return multiport_name_; } }; template class MutationChangeMultiportSize; diff --git a/include/reactor-cpp/port.hh b/include/reactor-cpp/port.hh index e5b3da56..b1035ea8 100644 --- a/include/reactor-cpp/port.hh +++ b/include/reactor-cpp/port.hh @@ -189,7 +189,7 @@ public: Input(Input&&) = default; - ~Input() { std::cout << "Input port gets deallocated:" << this->fqn() << std::endl; } + ~Input() override { std::cout << "Input port gets deallocated:" << this->fqn() << "\n"; } }; template class Output : public Port { // NOLINT(cppcoreguidelines-special-member-functions) @@ -199,7 +199,7 @@ public: Output(Output&&) noexcept = default; - ~Output() { std::cout << "Output port gets deallocated: " << this->fqn() << std::endl; } + ~Output() override { std::cout << "Output port gets deallocated: " << this->fqn() << "\n"; } }; } // namespace reactor diff --git a/include/reactor-cpp/reaction.hh b/include/reactor-cpp/reaction.hh index 80246a28..76039504 100644 --- a/include/reactor-cpp/reaction.hh +++ b/include/reactor-cpp/reaction.hh @@ -27,7 +27,7 @@ private: std::set dependencies_; const int priority_ = -1; - unsigned int index_ = -1; + int index_ = -1; std::function body_{nullptr}; diff --git a/lib/action.cc b/lib/action.cc index 04a52a41..ed8a43a7 100644 --- a/lib/action.cc +++ b/lib/action.cc @@ -29,7 +29,7 @@ void BaseAction::register_trigger(Reaction* reaction) { validate(this->container() == reaction->container(), "Action triggers must belong to the same reactor as the triggered " "reaction"); - [[maybe_unused]] bool result = triggers_.insert(reaction).second; + [[maybe_unused]] const bool result = triggers_.insert(reaction).second; reactor_assert(result); } @@ -40,7 +40,7 @@ void BaseAction::register_scheduler(Reaction* reaction) { // the reaction must belong to the same reactor as this action validate(this->container() == reaction->container(), "Scheduable actions must belong to the same reactor as the " "triggered reaction"); - [[maybe_unused]] bool result = schedulers_.insert(reaction).second; + [[maybe_unused]] const bool result = schedulers_.insert(reaction).second; reactor_assert(result); } @@ -62,8 +62,8 @@ void Timer::cleanup() noexcept { BaseAction::cleanup(); // schedule the timer again if (period_ != Duration::zero()) { - Tag now = Tag::from_logical_time(environment()->logical_time()); - Tag next = now.delay(period_); + const Tag now = Tag::from_logical_time(environment()->logical_time()); + const Tag next = now.delay(period_); environment()->scheduler()->schedule_sync(this, next); } } @@ -74,7 +74,7 @@ ShutdownTrigger::ShutdownTrigger(const std::string& name, Reactor* container) void ShutdownTrigger::setup() noexcept { BaseAction::setup(); } void ShutdownTrigger::shutdown() { - Tag tag = Tag::from_logical_time(environment()->logical_time()).delay(); + const Tag tag = Tag::from_logical_time(environment()->logical_time()).delay(); environment()->scheduler()->schedule_sync(this, tag); } diff --git a/lib/environment.cc b/lib/environment.cc index 9b86fd7a..d39a1a59 100644 --- a/lib/environment.cc +++ b/lib/environment.cc @@ -41,7 +41,7 @@ Environment::Environment(const std::string& name, Environment* containing_enviro , top_environment_(containing_environment_->top_environment_) , scheduler_(this) , timeout_(containing_environment->timeout()) { - [[maybe_unused]] bool result = containing_environment->contained_environments_.insert(this).second; + [[maybe_unused]] const bool result = containing_environment->contained_environments_.insert(this).second; reactor_assert(result); } @@ -50,7 +50,7 @@ void Environment::register_reactor(Reactor* reactor) { validate(this->phase() == Phase::Construction || this->phase() == Phase::Mutation, "Reactors may only be registered during construction phase!"); validate(reactor->is_top_level(), "The environment may only contain top level reactors!"); - [[maybe_unused]] bool result = top_level_reactors_.insert(reactor).second; + [[maybe_unused]] const bool result = top_level_reactors_.insert(reactor).second; reactor_assert(result); } @@ -58,7 +58,7 @@ void Environment::register_input_action(BaseAction* action) { reactor_assert(action != nullptr); validate(this->phase() == Phase::Construction || this->phase() == Phase::Assembly, "Input actions may only be registered during construction or assembly phase!"); - [[maybe_unused]] bool result = input_actions_.insert(action).second; + [[maybe_unused]] const bool result = input_actions_.insert(action).second; reactor_assert(result); run_forever_ = true; } diff --git a/lib/transaction.cc b/lib/transaction.cc index 3092b937..d33ea932 100644 --- a/lib/transaction.cc +++ b/lib/transaction.cc @@ -16,8 +16,8 @@ auto reactor::Transaction::execute(bool recalculate) -> MutationResult { if (recalculate) { this->environment_->clear_dependency_graph(); - for (const auto* reactor : this->environment_->top_level_reactors()) { - this->environment_->build_dependency_graph((Reactor*)reactor); + for (auto* reactor : this->environment_->top_level_reactors()) { + this->environment_->build_dependency_graph(reactor); } this->environment_->calculate_indexes();