X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b519c710a179e22b19c6d21721c6c0dfd13e65ce..b1233a583739b02023186b2a129805eb6594a4d5:/src/mc/api/strategy/WaitStrategy.hpp diff --git a/src/mc/api/strategy/WaitStrategy.hpp b/src/mc/api/strategy/WaitStrategy.hpp index edf75b2f39..ed5b9a0eed 100644 --- a/src/mc/api/strategy/WaitStrategy.hpp +++ b/src/mc/api/strategy/WaitStrategy.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_MC_WAITSTRATEGY_HPP #define SIMGRID_MC_WAITSTRATEGY_HPP +#include "Strategy.hpp" #include "src/mc/transition/Transition.hpp" namespace simgrid::mc { @@ -13,11 +14,18 @@ namespace simgrid::mc { /** Wait MC guiding class that aims at minimizing the number of in-fly communication. * When possible, it will try to take the wait transition. */ class WaitStrategy : public Strategy { - double taken_wait_ = 0; - bool taking_wait_ = false; + int taken_wait_ = 0; + bool taking_wait_ = false; public: - void operator=(const WaitStrategy& guide) { taken_wait_ = guide.taken_wait_; } + WaitStrategy() = default; + ~WaitStrategy() override = default; + WaitStrategy(const WaitStrategy&) = delete; + WaitStrategy& operator=(const WaitStrategy& guide) + { + taken_wait_ = guide.taken_wait_; + return *this; + } bool is_transition_wait(Transition::Type type) const { @@ -25,9 +33,9 @@ public: type == Transition::Type::MUTEX_WAIT or type == Transition::Type::SEM_WAIT; } - std::pair next_transition() const override + std::pair next_transition() const override { - std::pair if_no_wait = std::make_pair(-1, 0.0); + std::pair if_no_wait = std::make_pair(-1, 0); for (auto const& [aid, actor] : actors_to_run_) { if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) continue; @@ -43,7 +51,7 @@ public: * to decrease the count. */ void execute_next(aid_t aid, RemoteApp& app) override { - auto& actor = actors_to_run_.at(aid); + auto const& actor = actors_to_run_.at(aid); if ((not taking_wait_) and is_transition_wait(actor.get_transition(actor.get_times_considered())->type_)) { taken_wait_++; taking_wait_ = true; @@ -58,9 +66,8 @@ public: void consider_best() override { - const auto& [aid, _] = this->next_transition(); - auto actor = actors_to_run_.find(aid); - if (actor != actors_to_run_.end()) { + aid_t aid = next_transition().first; + if (auto actor = actors_to_run_.find(aid); actor != actors_to_run_.end()) { actor->second.mark_todo(); return; }