Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Handle simcall result through mc::SimcallObserver.
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index 4d9f023..460edbc 100644 (file)
@@ -8,6 +8,7 @@
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/modelchecker.h"
 #include "simgrid/s4u/Exec.hpp"
+#include "src/mc/checker/SimcallObserver.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
 
 #include "simgrid/s4u/Host.hpp"
 
-#include <boost/range/algorithm.hpp>
-
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
-void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall,
-                                           const std::vector<simgrid::kernel::activity::ExecImpl*>* execs,
-                                           double timeout)
-{
-  simgrid::kernel::activity::ExecImpl::wait_any_for(simcall->issuer_, execs, timeout);
-}
-
 namespace simgrid {
 namespace kernel {
 namespace activity {
@@ -173,15 +165,11 @@ void ExecImpl::finish()
 
     if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
       continue;                                 // if process handling comm is killed
-    if (simcall->call_ == simix::Simcall::EXECUTION_WAITANY_FOR) {
-      const std::vector<simgrid::kernel::activity::ExecImpl*>* execs =
-          simcall_execution_waitany_for__get__execs(simcall);
+    if (auto* observer = dynamic_cast<mc::ExecutionWaitanySimcall*>(simcall->observer_)) { // simcall is a wait_any?
+      const auto* execs = observer->get_execs();
 
       for (auto* exec : *execs) {
-        // Remove the first occurrence of simcall:
-        auto j = boost::range::find(exec->simcalls_, simcall);
-        if (j != exec->simcalls_.end())
-          exec->simcalls_.erase(j);
+        exec->unregister_simcall(simcall);
 
         if (simcall->timeout_cb_) {
           simcall->timeout_cb_->remove();
@@ -191,8 +179,8 @@ void ExecImpl::finish()
 
       if (not MC_is_active() && not MC_record_replay_is_active()) {
         auto element = std::find(execs->begin(), execs->end(), this);
-        int rank     = (element != execs->end()) ? std::distance(execs->begin(), element) : -1;
-        simcall_execution_waitany_for__set__result(simcall, rank);
+        int rank     = element != execs->end() ? static_cast<int>(std::distance(execs->begin(), element)) : -1;
+        observer->set_result(rank);
       }
     }
     switch (state_) {
@@ -261,13 +249,9 @@ void ExecImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl
   } else {
     issuer->simcall_.timeout_cb_ = simgrid::simix::Timer::set(SIMIX_get_clock() + timeout, [issuer, execs]() {
       issuer->simcall_.timeout_cb_ = nullptr;
-      for (auto* exec : *execs) {
-        // Remove the first occurrence of simcall:
-        auto j = boost::range::find(exec->simcalls_, &issuer->simcall_);
-        if (j != exec->simcalls_.end())
-          exec->simcalls_.erase(j);
-      }
-      simcall_execution_waitany_for__set__result(&issuer->simcall_, -1);
+      for (auto* exec : *execs)
+        exec->unregister_simcall(&issuer->simcall_);
+      // default result (-1) is set in mc::ExecutionWaitanySimcall
       issuer->simcall_answer();
     });
   }