Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: Kill the now useless code State::get_recipe
[simgrid.git] / src / mc / api / State.cpp
index 38b0a35..a178f55 100644 (file)
@@ -27,8 +27,6 @@ State::State(RemoteApp& remote_app) : num_(++expended_states_)
   else
     THROW_IMPOSSIBLE;
 
-  recipe_ = std::list<Transition*>();
-
   remote_app.get_actors_status(strategy_->actors_to_run_);
 
 #if SIMGRID_HAVE_STATEFUL_MC
@@ -40,7 +38,7 @@ State::State(RemoteApp& remote_app) : num_(++expended_states_)
 }
 
 State::State(RemoteApp& remote_app, std::shared_ptr<State> parent_state)
-    : num_(++expended_states_), parent_state_(parent_state)
+    : incoming_transition_(parent_state->get_transition_out()), num_(++expended_states_), parent_state_(parent_state)
 {
   if (_sg_mc_strategy == "none")
     strategy_ = std::make_shared<BasicStrategy>();
@@ -50,9 +48,6 @@ State::State(RemoteApp& remote_app, std::shared_ptr<State> parent_state)
     THROW_IMPOSSIBLE;
   *strategy_ = *(parent_state->strategy_);
 
-  recipe_ = std::list(parent_state_->get_recipe());
-  recipe_.push_back(parent_state_->get_transition());
-
   remote_app.get_actors_status(strategy_->actors_to_run_);
 
 #if SIMGRID_HAVE_STATEFUL_MC /* Stateful model checking */
@@ -67,7 +62,7 @@ State::State(RemoteApp& remote_app, std::shared_ptr<State> parent_state)
      * And if we kept it and the actor is enabled in this state, mark the actor as already done, so that
      * it is not explored*/
     for (auto& [aid, transition] : parent_state_->get_sleep_set()) {
-      if (not parent_state_->get_transition()->depends(&transition)) {
+      if (not incoming_transition_->depends(&transition)) {
         sleep_set_.try_emplace(aid, transition);
         if (strategy_->actors_to_run_.count(aid) != 0) {
           XBT_DEBUG("Actor %ld will not be explored, for it is in the sleep set", aid);
@@ -75,8 +70,8 @@ State::State(RemoteApp& remote_app, std::shared_ptr<State> parent_state)
           strategy_->actors_to_run_.at(aid).mark_done();
         }
       } else
-        XBT_DEBUG("Transition >>%s<< removed from the sleep set because it was dependent with >>%s<<",
-                  transition.to_string().c_str(), parent_state_->get_transition()->to_string().c_str());
+        XBT_DEBUG("Transition >>%s<< removed from the sleep set because it was dependent with incoming >>%s<<",
+                  transition.to_string().c_str(), incoming_transition_->to_string().c_str());
     }
   }
 }
@@ -96,11 +91,6 @@ std::size_t State::count_todo_multiples() const
   return count;
 }
 
-Transition* State::get_transition() const
-{
-  return transition_;
-}
-
 aid_t State::next_transition() const
 {
   XBT_DEBUG("Search for an actor to run. %zu actors to consider", strategy_->actors_to_run_.size());
@@ -130,7 +120,7 @@ std::pair<aid_t, int> State::next_transition_guided() const
 }
 
 // This should be done in GuidedState, or at least interact with it
-void State::execute_next(aid_t next, RemoteApp& app)
+std::shared_ptr<Transition> State::execute_next(aid_t next, RemoteApp& app)
 {
   // First, warn the guide, so it knows how to build a proper child state
   strategy_->execute_next(next, app);
@@ -163,11 +153,11 @@ void State::execute_next(aid_t next, RemoteApp& app)
   //  2. what action actor `next` was able to take given `times_considered`
   // The latter update is important as *more* information is potentially available
   // about a transition AFTER it has executed.
-  transition_ = just_executed;
-
-  auto executed_transition = std::unique_ptr<Transition>(just_executed);
-  actor_state.set_transition(std::move(executed_transition), times_considered);
+  outgoing_transition_ = std::shared_ptr<Transition>(just_executed);
 
+  actor_state.set_transition(outgoing_transition_, times_considered);
   app.wait_for_requests();
+
+  return outgoing_transition_;
 }
 } // namespace simgrid::mc