Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix root-node edge cases for states
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Thu, 16 Feb 2023 12:11:07 +0000 (13:11 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Thu, 16 Feb 2023 13:33:59 +0000 (14:33 +0100)
src/mc/api/State.cpp
src/mc/api/State.hpp

index dfb48f3..1cdc87e 100644 (file)
@@ -14,7 +14,7 @@ namespace simgrid::mc {
 
 long State::expended_states_ = 0;
 
-State::State(const RemoteApp& remote_app) : num_(++expended_states_)
+State::State(const RemoteApp& remote_app) : default_transition(std::make_unique<Transition>()), num_(++expended_states_)
 {
   remote_app.get_actors_status(actors_to_run_);
 
@@ -31,6 +31,9 @@ std::size_t State::count_todo() const
 
 Transition* State::get_transition() const
 {
+  if (transition_ == nullptr) {
+    return default_transition.get();
+  }
   return transition_;
 }
 
index 08a4ecf..f3fe4b2 100644 (file)
@@ -22,9 +22,15 @@ class XBT_PRIVATE State : public xbt::Extendable<State> {
    * we took to leave this state?
    *
    * The owner of the transition is the `ActorState` instance which exists in this state,
-   * or nullptr if the state represents the root
+   * or a reference to the internal default transition `Transition()` if no transition has been
+   * set
    */
-  Transition* transition_ = nullptr;
+  Transition* transition_;
+
+  /**
+   * @brief An empty transition that leads to this state by default
+   */
+  const std::unique_ptr<Transition> default_transition;
 
   /** Sequential state ID (used for debugging) */
   long num_ = 0;