Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove constraint from LinkImpl ctor
[simgrid.git] / src / surf / network_cm02.cpp
index ac6e216..4f8dbb5 100644 (file)
@@ -97,10 +97,10 @@ LinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vect
                                         s4u::Link::SharingPolicy policy)
 {
   if (policy == s4u::Link::SharingPolicy::WIFI)
-    return new NetworkWifiLink(name, bandwidths, get_maxmin_system());
+    return (new NetworkWifiLink(name, bandwidths, get_maxmin_system()))->set_model(this);
 
   xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
-  return new NetworkCm02Link(name, bandwidths[0], policy, get_maxmin_system());
+  return (new NetworkCm02Link(name, bandwidths[0], policy, get_maxmin_system()))->set_model(this);
 }
 
 void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
@@ -310,10 +310,11 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
  ************/
 NetworkCm02Link::NetworkCm02Link(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy,
                                  kernel::lmm::System* system)
-    : LinkImpl(name, system->constraint_new(this, sg_bandwidth_factor * bandwidth))
+    : LinkImpl(name)
 {
   bandwidth_.scale = 1.0;
   bandwidth_.peak  = bandwidth;
+  this->set_constraint(system->constraint_new(this, sg_bandwidth_factor * bandwidth));
 
   if (policy == s4u::Link::SharingPolicy::FATPIPE)
     get_constraint()->unshare();