Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make field 'mc::ActorState::times_considered' private.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 21 Jun 2021 14:13:58 +0000 (16:13 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 22 Jun 2021 15:20:07 +0000 (17:20 +0200)
src/mc/api.cpp
src/mc/mc_pattern.hpp

index d1628af..cdb3224 100644 (file)
@@ -108,25 +108,23 @@ static inline smx_simcall_t MC_state_choose_request_for_process(const RemoteProc
 
   smx_simcall_t req = nullptr;
   if (actor->simcall_.observer_ != nullptr) {
-    state->transition_.times_considered_ = procstate->times_considered;
-    procstate->times_considered++;
-    if (actor->simcall_.mc_max_consider_ <= procstate->times_considered)
+    state->transition_.times_considered_ = procstate->get_times_considered_and_inc();
+    if (actor->simcall_.mc_max_consider_ <= procstate->get_times_considered())
       procstate->set_done();
     req = &actor->simcall_;
   } else
     switch (actor->simcall_.call_) {
       case Simcall::COMM_WAITANY:
         state->transition_.times_considered_ = -1;
-        while (procstate->times_considered < simcall_comm_waitany__get__count(&actor->simcall_)) {
-          if (simgrid::mc::request_is_enabled_by_idx(process, &actor->simcall_, procstate->times_considered)) {
-            state->transition_.times_considered_ = procstate->times_considered;
-            ++procstate->times_considered;
+        while (procstate->get_times_considered() < simcall_comm_waitany__get__count(&actor->simcall_)) {
+          if (simgrid::mc::request_is_enabled_by_idx(process, &actor->simcall_, procstate->get_times_considered())) {
+            state->transition_.times_considered_ = procstate->get_times_considered_and_inc();
             break;
           }
-          ++procstate->times_considered;
+          procstate->get_times_considered_and_inc();
         }
 
-        if (procstate->times_considered >= simcall_comm_waitany__get__count(&actor->simcall_))
+        if (procstate->get_times_considered() >= simcall_comm_waitany__get__count(&actor->simcall_))
           procstate->set_done();
         if (state->transition_.times_considered_ != -1)
           req = &actor->simcall_;
@@ -134,16 +132,15 @@ static inline smx_simcall_t MC_state_choose_request_for_process(const RemoteProc
 
       case Simcall::COMM_TESTANY:
         state->transition_.times_considered_ = -1;
-        while (procstate->times_considered < simcall_comm_testany__get__count(&actor->simcall_)) {
-          if (simgrid::mc::request_is_enabled_by_idx(process, &actor->simcall_, procstate->times_considered)) {
-            state->transition_.times_considered_ = procstate->times_considered;
-            ++procstate->times_considered;
+        while (procstate->get_times_considered() < simcall_comm_testany__get__count(&actor->simcall_)) {
+          if (simgrid::mc::request_is_enabled_by_idx(process, &actor->simcall_, procstate->get_times_considered())) {
+            state->transition_.times_considered_ = procstate->get_times_considered_and_inc();
             break;
           }
-          ++procstate->times_considered;
+          procstate->get_times_considered_and_inc();
         }
 
-        if (procstate->times_considered >= simcall_comm_testany__get__count(&actor->simcall_))
+        if (procstate->get_times_considered() >= simcall_comm_testany__get__count(&actor->simcall_))
           procstate->set_done();
         if (state->transition_.times_considered_ != -1)
           req = &actor->simcall_;
index 79bcd24..bb26c9d 100644 (file)
@@ -67,23 +67,25 @@ class ActorState {
   };
 
   /** Exploration control information */
-  InterleavingType state = InterleavingType::disabled;
+  InterleavingType state_ = InterleavingType::disabled;
 
-public:
   /** Number of times that the process was considered to be executed */
-  // TODO, make this private
-  unsigned int times_considered = 0;
+  unsigned int times_considered_ = 0;
+
+public:
+  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; }
-  bool is_todo() const { return this->state == InterleavingType::todo; }
+  bool is_disabled() const { return this->state_ == InterleavingType::disabled; }
+  bool is_done() const { return this->state_ == InterleavingType::done; }
+  bool is_todo() const { return this->state_ == InterleavingType::todo; }
   /** Mark that we should try executing this process at some point in the future of the checker algorithm */
   void mark_todo()
   {
-    this->state            = InterleavingType::todo;
-    this->times_considered = 0;
+    this->state_            = InterleavingType::todo;
+    this->times_considered_ = 0;
   }
-  void set_done() { this->state = InterleavingType::done; }
+  void set_done() { this->state_ = InterleavingType::done; }
 };
 
 } // namespace mc