]> AND Public Git Repository - simgrid.git/blobdiff - src/kernel/activity/IoImpl.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Const methods.
[simgrid.git] / src / kernel / activity / IoImpl.cpp
index f2c5bdcafe9f6b06f7dc9749356c7de331604899..61c160b931a529e66d6b4dba6aa334fdaff8b251 100644 (file)
@@ -17,7 +17,7 @@
 #include "src/kernel/resource/DiskImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_io, kernel, "Kernel io-related synchronization");
 
 namespace simgrid {
 namespace kernel {
@@ -147,24 +147,8 @@ void IoImpl::finish()
 
     if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
       continue;                                 // if process handling comm is killed
-    if (auto* observer = dynamic_cast<kernel::actor::IoWaitanySimcall*>(simcall->observer_)) { // simcall is a wait_any?
-      const auto& ios = observer->get_ios();
-
-      for (auto* io : ios) {
-        io->unregister_simcall(simcall);
-
-        if (simcall->timeout_cb_) {
-          simcall->timeout_cb_->remove();
-          simcall->timeout_cb_ = nullptr;
-        }
-      }
-
-      if (not MC_is_active() && not MC_record_replay_is_active()) {
-        auto element = std::find(ios.begin(), ios.end(), this);
-        int rank     = element != ios.end() ? static_cast<int>(std::distance(ios.begin(), element)) : -1;
-        observer->set_result(rank);
-      }
-    }
+
+    handle_activity_waitany(simcall);
 
     set_exception(simcall->issuer_);
 
@@ -173,32 +157,6 @@ void IoImpl::finish()
   }
 }
 
-void IoImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<IoImpl*>& ios, double timeout)
-{
-  if (timeout < 0.0) {
-    issuer->simcall_.timeout_cb_ = nullptr;
-  } else {
-    issuer->simcall_.timeout_cb_ = timer::Timer::set(s4u::Engine::get_clock() + timeout, [issuer, &ios]() {
-      issuer->simcall_.timeout_cb_ = nullptr;
-      for (auto* io : ios)
-        io->unregister_simcall(&issuer->simcall_);
-      // default result (-1) is set in actor::IoWaitanySimcall
-      issuer->simcall_answer();
-    });
-  }
-
-  for (auto* io : ios) {
-    /* associate this simcall to the the synchro */
-    io->simcalls_.push_back(&issuer->simcall_);
-
-    /* see if the synchro is already finished */
-    if (io->get_state() != State::WAITING && io->get_state() != State::RUNNING) {
-      io->finish();
-      break;
-    }
-  }
-}
-
 } // namespace activity
 } // namespace kernel
 } // namespace simgrid