Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use Ptr to store disks of a HostImpl, do not care about cleanup anymore
[simgrid.git] / src / kernel / resource / StandardLinkImpl.cpp
index 6876a4b..9df40d0 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <simgrid/s4u/Engine.hpp>
 
-#include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/StandardLinkImpl.hpp"
 #include <numeric>
 
@@ -37,6 +36,7 @@ void StandardLinkImpl::Deleter::operator()(resource::StandardLinkImpl* link) con
 void StandardLinkImpl::destroy()
 {
   s4u::Link::on_destruction(piface_);
+  piface_.on_this_destruction(piface_);
   delete this;
 }
 
@@ -64,8 +64,8 @@ void StandardLinkImpl::latency_check(double latency) const
 {
   static double last_warned_latency = sg_precision_timing;
   if (latency != 0.0 && latency < last_warned_latency) {
-    XBT_WARN("Latency for link %s is smaller than surf/precision (%g < %g)."
-             " For more accuracy, consider setting \"--cfg=surf/precision:%g\".",
+    XBT_WARN("Latency for link %s is smaller than precision/timing (%g < %g)."
+             " For more accuracy, consider setting \"--cfg=precision/timing:%g\".",
              get_cname(), latency, sg_precision_timing, latency);
     last_warned_latency = latency;
   }
@@ -81,7 +81,8 @@ void StandardLinkImpl::turn_on()
 {
   if (not is_on()) {
     Resource::turn_on();
-    s4u::Link::on_state_change(piface_);
+    s4u::Link::on_onoff(piface_);
+    piface_.on_this_onoff(piface_);
   }
 }
 
@@ -89,17 +90,9 @@ void StandardLinkImpl::turn_off()
 {
   if (is_on()) {
     Resource::turn_off();
-    s4u::Link::on_state_change(piface_);
-
-    const kernel::lmm::Element* elem = nullptr;
-    double now                       = EngineImpl::get_clock();
-    while (const auto* var = get_constraint()->get_variable(&elem)) {
-      Action* action = var->get_id();
-      if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) {
-        action->set_finish_time(now);
-        action->set_state(Action::State::FAILED);
-      }
-    }
+    s4u::Link::on_onoff(piface_);
+    piface_.on_this_onoff(piface_);
+    cancel_actions();
   }
 }
 
@@ -115,6 +108,7 @@ void StandardLinkImpl::seal()
 void StandardLinkImpl::on_bandwidth_change() const
 {
   s4u::Link::on_bandwidth_change(piface_);
+  piface_.on_this_bandwidth_change(piface_);
 }
 
 void StandardLinkImpl::set_bandwidth_profile(profile::Profile* profile)
@@ -133,16 +127,4 @@ void StandardLinkImpl::set_latency_profile(profile::Profile* profile)
   }
 }
 
-void StandardLinkImpl::set_concurrency_limit(int limit) const
-{
-  if (limit != -1) {
-    get_constraint()->reset_concurrency_maximum();
-  }
-  get_constraint()->set_concurrency_limit(limit);
-}
-int StandardLinkImpl::get_concurrency_limit() const
-{
-  return get_constraint()->get_concurrency_limit();
-}
-
 } // namespace simgrid::kernel::resource