Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define ActivityImpl::set_timeout().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 10 Feb 2020 14:59:33 +0000 (15:59 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 10 Feb 2020 15:06:16 +0000 (16:06 +0100)
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/ExecImpl.hpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/IoImpl.hpp
src/kernel/activity/SynchroRaw.hpp

index b0562ff..dbc48bd 100644 (file)
@@ -45,6 +45,7 @@ public:
   resource::Action* surf_action_ = nullptr;
 
   bool test();
+  virtual ActivityImpl& set_timeout(double timeout) { THROW_UNIMPLEMENTED; }
 
   virtual void suspend();
   virtual void resume();
index 7d4a915..0a3180c 100644 (file)
@@ -24,7 +24,7 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
   std::vector<double> bytes_amounts_;
 
 public:
-  ExecImpl& set_timeout(double timeout);
+  ExecImpl& set_timeout(double timeout) override;
   ExecImpl& set_bound(double bound);
   ExecImpl& set_sharing_penalty(double sharing_penalty);
 
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);
   }
 }
 
index ac5c395..92680f7 100644 (file)
@@ -23,17 +23,12 @@ class XBT_PUBLIC IoImpl : public ActivityImpl_T<IoImpl> {
   resource::Action* timeout_detector_ = nullptr;
 
 public:
+  IoImpl& set_timeout(double timeout) override;
   IoImpl& set_size(sg_size_t size);
   IoImpl& set_type(s4u::Io::OpType type);
   IoImpl& set_storage(resource::StorageImpl* storage);
   IoImpl& set_disk(resource::DiskImpl* disk);
 
-  void set_timeout_detector(resource::Action* action)
-  {
-    timeout_detector_ = action;
-    timeout_detector_->set_activity(this);
-  }
-
   sg_size_t get_performed_ioops() const { return performed_ioops_; }
   resource::DiskImpl* get_disk() const { return disk_; }
   resource::StorageImpl* get_storage() const { return storage_; }
index 6d45f90..8ff877e 100644 (file)
@@ -20,7 +20,7 @@ class XBT_PUBLIC RawImpl : public ActivityImpl_T<RawImpl> {
 
 public:
   RawImpl& set_host(s4u::Host* host);
-  RawImpl& set_timeout(double timeout);
+  RawImpl& set_timeout(double timeout) override;
 
   RawImpl* start();
   void suspend() override;