Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define ActivityImpl::set_timeout().
[simgrid.git] / src / kernel / activity / IoImpl.cpp
index 9a2e3f0..a246446 100644 (file)
@@ -24,6 +24,14 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
+IoImpl& IoImpl::set_timeout(double timeout)
+{
+  s4u::Host* host   = get_disk() ? get_disk()->get_host() : s4u::Host::by_name(get_storage()->get_host());
+  timeout_detector_ = host->pimpl_cpu->sleep(timeout);
+  timeout_detector_->set_activity(this);
+  return *this;
+}
+
 IoImpl& IoImpl::set_type(s4u::Io::OpType type)
 {
   type_ = type;
@@ -90,10 +98,7 @@ void IoImpl::wait_for(actor::ActorImpl* issuer, double timeout)
     finish();
   else {
     /* we need a sleep action (even when there is no timeout) to be notified of host failures */
-    if (get_disk() != nullptr)
-      set_timeout_detector(get_disk()->get_host()->pimpl_cpu->sleep(timeout));
-    else
-      set_timeout_detector(simgrid::s4u::Host::by_name(get_storage()->get_host())->pimpl_cpu->sleep(timeout));
+    set_timeout(timeout);
   }
 }