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*/)
************/
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();
* Resource *
************/
-LinkImpl::LinkImpl(const std::string& name, lmm::Constraint* constraint) : Resource_T(name), piface_(this)
+LinkImpl::LinkImpl(const std::string& name) : Resource_T(name), piface_(this)
{
- this->set_constraint(constraint);
if (name != "__loopback__")
xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str());
void LinkImpl::seal()
{
- this->set_model(surf_network_model);
Resource::seal();
simgrid::s4u::Link::on_creation(*get_iface());
}
s4u::Link piface_;
protected:
- LinkImpl(const std::string& name, lmm::Constraint* constraint);
+ LinkImpl(const std::string& name);
LinkImpl(const LinkImpl&) = delete;
LinkImpl& operator=(const LinkImpl&) = delete;
~LinkImpl() override = default; // Use destroy() instead of this destructor.
************/
LinkNS3::LinkNS3(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy)
- : LinkImpl(name, nullptr), sharing_policy_(policy)
+ : LinkImpl(name), sharing_policy_(policy)
{
bandwidth_.peak = bandwidth;
}
************/
NetworkWifiLink::NetworkWifiLink(const std::string& name, std::vector<double> bandwidths, lmm::System* system)
- : LinkImpl(name, system->constraint_new(this, 1))
+ : LinkImpl(name)
{
+ this->set_constraint(system->constraint_new(this, 1));
for (auto bandwidth : bandwidths)
bandwidths_.push_back({bandwidth, 1.0, nullptr});
}
CpuL07::~CpuL07()=default;
-LinkL07::LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy,
- kernel::lmm::System* system)
- : LinkImpl(name, system->constraint_new(this, bandwidth))
-{
- bandwidth_.peak = bandwidth;
-
- if (policy == s4u::Link::SharingPolicy::FATPIPE)
- get_constraint()->unshare();
-}
-
kernel::resource::CpuAction* CpuL07::execution_start(double size)
{
std::vector<s4u::Host*> host_list = {get_iface()};
Cpu::on_speed_change();
}
+LinkL07::LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy,
+ kernel::lmm::System* system)
+ : LinkImpl(name)
+{
+ this->set_constraint(system->constraint_new(this, bandwidth));
+ bandwidth_.peak = bandwidth;
+
+ if (policy == s4u::Link::SharingPolicy::FATPIPE)
+ get_constraint()->unshare();
+}
+
bool LinkL07::is_used() const
{
return get_model()->get_maxmin_system()->constraint_used(get_constraint());