Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: better encapsulation design
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 23 May 2022 22:36:32 +0000 (00:36 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 10 Jun 2022 07:37:22 +0000 (09:37 +0200)
src/mc/api/State.cpp
src/mc/mc_pattern.hpp

index e3048b1..fac456f 100644 (file)
@@ -54,18 +54,13 @@ int State::next_transition() const
 void State::execute_next(int next)
 {
   std::vector<ActorInformation>& actors = mc_model_checker->get_remote_process().actors();
-
   const kernel::actor::ActorImpl* actor = actors[next].copy.get_buffer();
-  aid_t aid                       = actor->get_pid();
-  int times_considered;
+  const aid_t aid                       = actor->get_pid();
 
-  simgrid::mc::ActorState* actor_state = &actor_states_[aid];
   /* This actor is ready to be executed. Prepare its execution when simcall_handle will be called on it */
-  times_considered = actor_state->get_times_considered_and_inc();
-  if (actor->simcall_.mc_max_consider_ <= actor_state->get_times_considered())
-    actor_state->set_done();
+  const unsigned times_considered = actor_states_[aid].do_consider(actor->simcall_.mc_max_consider_);
 
-  XBT_DEBUG("Let's run actor %ld (times_considered = %d)", aid, times_considered);
+  XBT_DEBUG("Let's run actor %ld (times_considered = %u)", aid, times_considered);
 
   Transition::executed_transitions_++;
 
index 8702a24..e29895c 100644 (file)
@@ -35,8 +35,13 @@ class ActorState {
   unsigned int times_considered_ = 0;
 
 public:
+  unsigned int do_consider(unsigned int max_consider)
+  {
+    if (max_consider <= times_considered_ + 1)
+      set_done();
+    return times_considered_++;
+  }
   unsigned int get_times_considered() const { return times_considered_; }
-  unsigned int get_times_considered_and_inc() { return times_considered_++; }
 
   bool is_disabled() const { return this->state_ == InterleavingType::disabled; }
   bool is_done() const { return this->state_ == InterleavingType::done; }