Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove more uses of the session global
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 14 Mar 2021 02:04:23 +0000 (03:04 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 14 Mar 2021 02:09:04 +0000 (03:09 +0100)
src/mc/api.cpp
src/mc/api.hpp
src/mc/checker/Checker.hpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/checker/LivenessChecker.cpp
src/mc/checker/SafetyChecker.cpp

index b6cee6c..833c7df 100644 (file)
@@ -455,11 +455,6 @@ std::vector<simgrid::mc::ActorInformation>& Api::get_actors() const
   return mc_model_checker->get_remote_process().actors();
 }
 
-bool Api::actor_is_enabled(aid_t pid) const
-{
-  return session->actor_is_enabled(pid);
-}
-
 unsigned long Api::get_maxpid() const
 {
   static const char* name = nullptr;
index 3e4f3e6..36730ee 100644 (file)
@@ -69,7 +69,6 @@ public:
 
   // ACTOR APIs
   std::vector<simgrid::mc::ActorInformation>& get_actors() const;
-  bool actor_is_enabled(aid_t pid) const;
   unsigned long get_maxpid() const;
   int get_actors_size() const;
 
index ebc0448..c0ba4a3 100644 (file)
@@ -55,7 +55,7 @@ public:
   /** Log additional information about the state of the model-checker */
   virtual void log_state() = 0;
 
-  Session* get_session() { return session_; }
+  Session& get_session() { return *session_; }
 };
 
 // External constructors so that the types (and the types of their content) remain hidden
index 9c179ab..6ae7e10 100644 (file)
@@ -316,7 +316,7 @@ void CommunicationDeterminismChecker::prepare()
   /* Add all enabled actors to the interleave set of the initial state */
   for (auto& act : api::get().get_actors()) {
     auto actor = act.copy.get_buffer();
-    if (api::get().actor_is_enabled(actor->get_pid()))
+    if (get_session().actor_is_enabled(actor->get_pid()))
       initial_state->mark_todo(actor);
   }
 
@@ -471,7 +471,7 @@ void CommunicationDeterminismChecker::real_run()
         /* Add all enabled actors to the interleave set of the next state */
         for (auto& act : api::get().get_actors()) {
           auto actor = act.copy.get_buffer();
-          if (api::get().actor_is_enabled(actor->get_pid()))
+          if (get_session().actor_is_enabled(actor->get_pid()))
             next_state->mark_todo(actor);
         }
 
@@ -528,7 +528,7 @@ void CommunicationDeterminismChecker::real_run()
 void CommunicationDeterminismChecker::run()
 {
   XBT_INFO("Check communication determinism");
-  get_session()->take_initial_snapshot();
+  get_session().take_initial_snapshot();
 
   this->prepare();
   this->real_run();
index c3730a9..ebdddcf 100644 (file)
@@ -259,7 +259,7 @@ std::shared_ptr<Pair> LivenessChecker::create_pair(const Pair* current_pair, xbt
   /* Add all enabled actors to the interleave set of the initial state */
   for (auto& act : api::get().get_actors()) {
     auto actor = act.copy.get_buffer();
-    if (api::get().actor_is_enabled(actor->get_pid()))
+    if (get_session().actor_is_enabled(actor->get_pid()))
       next_pair->graph_state->mark_todo(actor);
   }
 
@@ -300,7 +300,7 @@ void LivenessChecker::run()
   api::get().automaton_load(_sg_mc_property_file.get().c_str());
 
   XBT_DEBUG("Starting the liveness algorithm");
-  get_session()->take_initial_snapshot();
+  get_session().take_initial_snapshot();
 
   /* Initialize */
   this->previous_pair_ = 0;
index cb8762a..2bc2bdb 100644 (file)
@@ -147,7 +147,7 @@ void SafetyChecker::run()
       auto actors = api::get().get_actors(); 
       for (auto& remoteActor : actors) {
         auto actor = remoteActor.copy.get_buffer();
-        if (api::get().actor_is_enabled(actor->get_pid())) {
+        if (get_session().actor_is_enabled(actor->get_pid())) {
           next_state->mark_todo(actor);
           if (reductionMode_ == ReductionMode::dpor)
             break; // With DPOR, we take the first enabled transition
@@ -267,7 +267,7 @@ SafetyChecker::SafetyChecker(Session* session) : Checker(session)
              (reductionMode_ == ReductionMode::none ? "none"
                                                     : (reductionMode_ == ReductionMode::dpor ? "dpor" : "unknown")));
 
-  get_session()->take_initial_snapshot();
+  get_session().take_initial_snapshot();
 
   XBT_DEBUG("Starting the safety algorithm");
 
@@ -280,7 +280,7 @@ SafetyChecker::SafetyChecker(Session* session) : Checker(session)
   /* Get an enabled actor and insert it in the interleave set of the initial state */
   auto actors = api::get().get_actors();
   for (auto& actor : actors)
-    if (api::get().actor_is_enabled(actor.copy.get_buffer()->get_pid())) {
+    if (get_session().actor_is_enabled(actor.copy.get_buffer()->get_pid())) {
       initial_state->mark_todo(actor.copy.get_buffer());
       if (reductionMode_ != ReductionMode::none)
         break;