Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authormlaurent <mathieu.laurent@ens-rennes.fr>
Thu, 16 Feb 2023 09:09:38 +0000 (10:09 +0100)
committermlaurent <mathieu.laurent@ens-rennes.fr>
Thu, 16 Feb 2023 09:09:38 +0000 (10:09 +0100)
1  2 
src/mc/api/ActorState.hpp
src/mc/api/State.cpp
src/mc/api/State.hpp

@@@ -70,7 -113,25 +113,25 @@@ public
      this->state_            = InterleavingType::todo;
      this->times_considered_ = 0;
    }
 -  void set_done() { this->state_ = InterleavingType::done; }
 +  void mark_done() { this->state_ = InterleavingType::done; }
+   inline Transition* get_transition(unsigned times_considered)
+   {
+     xbt_assert(times_considered < this->pending_transitions_.size(),
+                "Actor %lu does not have a state available transition with `times_considered = %d`,\n"
+                "yet one was asked for",
+                aid_, times_considered);
+     return this->pending_transitions_[times_considered].get();
+   }
+   inline void set_transition(std::unique_ptr<Transition> t, unsigned times_considered)
+   {
+     xbt_assert(times_considered < this->pending_transitions_.size(),
+                "Actor %lu does not have a state available transition with `times_considered = %d`, "
+                "yet one was attempted to be set",
+                aid_, times_considered);
+     this->pending_transitions_[times_considered] = std::move(t);
+   }
  };
  
  } // namespace simgrid::mc
@@@ -62,19 -29,9 +61,19 @@@ std::size_t State::count_todo() cons
    return boost::range::count_if(this->actors_to_run_, [](auto& pair) { return pair.second.is_todo(); });
  }
  
 +void State::mark_all_todo() 
 +{
 +    for (auto & [aid, actor] : actors_to_run_) {
 +
 +      if (actor.is_enabled() and not actor.is_done() and not actor.is_todo())
 +          actor.mark_todo();
 +      
 +    }
 +}
 +    
  Transition* State::get_transition() const
  {
-   return transition_.get();
 -  return transition_;
++    return transition_;
  }
  
  aid_t State::next_transition() const
@@@ -46,11 -48,9 +53,11 @@@ public
    long get_num() const { return num_; }
    std::size_t count_todo() const;
    void mark_todo(aid_t actor) { actors_to_run_.at(actor).mark_todo(); }
 +  void mark_done(aid_t actor) { actors_to_run_.at(actor).mark_done();}
 +  void mark_all_todo();
    bool is_done(aid_t actor) const { return actors_to_run_.at(actor).is_done(); }
    Transition* get_transition() const;
-   void set_transition(Transition* t) { transition_.reset(t); }
+   void set_transition(Transition* t) { transition_ = t; }
    std::map<aid_t, ActorState> const& get_actors_list() const { return actors_to_run_; }
  
    unsigned long get_actor_count() const { return actors_to_run_.size(); }